WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Version and Dir Mgmt

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Directory Compare Report

 Keywords: Directory Folder Compare Comparison Report 

TestFirstDir = "D:\FolderA\"
TestSecondDir = "D:\FolderB\"

DirChange (TestFirstDir)
ListDir1 = StrLower (FileItemize ("*.*"))
ListDir1 = ItemSort (ListDir1, @TAB)
CountDir1 = ItemCount (listDir1, @TAB)

DirChange (TestSecondDir)
ListDir2 = StrLower (FileItemize ("*.*"))
ListDir2 = ItemSort (ListDir2, @TAB)
CountDir2 = ItemCount (listDir2, @TAB)
;;;;;;
FilesInFirstNotInSecond = ListDir1
For xx = 1 To CountDir2
   testfile = ItemExtract (xx, ListDir2, @TAB)
   test = ItemLocate (testfile, FilesInFirstNotInSecond, @TAB)
   If test != 0
      FilesInFirstNotInSecond = ItemRemove (test, FilesInFirstNotInSecond, @TAB)
   EndIf
Next
;;;;;;
FilesInSecondNotInFirst = ListDir2
For xx = 1 To CountDir1
   testfile = ItemExtract (xx, ListDir1, @TAB)
   test = ItemLocate (testfile, FilesInSecondNotInFirst, @TAB)
   If test != 0
      FilesInSecondNotInFirst = ItemRemove (test, FilesInSecondNotInFirst, @TAB)
   EndIf
Next
;;;;;;
FilesInBoth = ""
FilesInBothAndDifferent = ""
For xx = 1 To CountDir1
   testfile = ItemExtract (xx, ListDir1, @TAB)
   test = ItemLocate (testfile, Listdir2, @TAB)
   If test != 0
      If FilesInBoth == "" Then FilesInBoth = testfile
         Else FilesInBoth = StrCat (FilesInBoth, @TAB, testfile)

      testfile1 = StrCat (TestFirstDir, testfile)
      testfile2 = StrCat (TestSecondDir, testfile)
      comptest = FileCompare (testfile1, testfile2)

      If comptest != 0
         If FilesInBothAndDifferent == "" Then FilesInBothAndDifferent = testfile
            Else FilesInBothAndDifferent = StrCat (FilesInBothAndDifferent, @TAB, testfile)
      EndIf
   EndIf
Next
;;;;;;
AskItemlist ("Only in %TestFirstDir%", FilesInFirstNotInSecond, @TAB, @UNSORTED, @SINGLE)
AskItemlist ("Only in %TestSecondDir%", FilesInSecondNotInFirst, @TAB, @UNSORTED, @SINGLE)
AskItemlist ("Files in both", FilesInBoth, @TAB, @UNSORTED, @SINGLE)
AskItemlist ("Files in both but different", FilesInBothAndDifferent, @TAB, @UNSORTED, @SINGLE)

:CANCEL
Exit

Article ID:   W18260
Filename:   Directory Compare Report.txt
File Created: 2010:08:23:08:19:04
Last Updated: 2010:08:23:08:19:04