I am manipulating a whole bunch of files and placing them in a different directory. What I need to do now is find out which files are in the original directory that aren't in the output directory (the problem is being processed by a dozen computers). Is there any script I can run on Windows that will display this?
I tend to use PathSync
you can try this vbscript, no need to download any stuff.
Set objFS = CreateObject("Scripting.FileSystemObject") Set d = CreateObject("Scripting.Dictionary") Set objArgs = WScript.Arguments strFolderA= objArgs(0) strFolderB = objArgs(1) Set objFolder = objFS.GetFolder(strFolderA) Set objFolder1 = objFS.GetFolder(strFolderB) For Each strFile In objFolder.Files strFileName = strFile.Name strFilePath = strFile.Path 'collect all files and their full paths. d.Add strFileName, strFilePath Next For Each strFile In objFolder1.Files strFileName = strFile.Name strFilePath = strFile.Path If Not d.Exists(strFileName) Then WScript.Echo "Not found in : " & strFolderA & "->" & strFilePath End If Next
C:\test>dir /B c:\tmp file test.bat C:\test>dir /B c:\tmp1 test.bat C:\test>cscript //nologo test.vbs c:\tmp1 c:\tmp Not found in : c:\tmp1->C:\tmp\file
FreeCommander does this quickly. Pick folder on right, pick folder on left, compare. It's a handy utility.
comm <options> <(cd $dir1;find -type <type>|sort) <(cd $dir2;find -type <type>|sort) |less -S
The comm command gives three columns of output unless you suppress them.
-S so less doesn't wrap and you can see the columns clearly.
-23shows what is unique to $dir1 in first column, suppresses other two columns
-13shows what is unique to $dir2 in second column, suppresses other two columns
-12shows every thing the same between $dir1 and $dir2, suppresses first two columns
f for just files
d for just directory or use type twice with both or remove type altogether for everything.
Note haven't tested the below I assume the pipe works in CMD.
If you got findutils and coreutils from here http://gnuwin32.sourceforge.net/packages.html (because you don't want cygwin) and the less package (but you can use
> \somepath\file instead of
|less -S then
notepad file etc).
cd %dir1% find -type <type> | sort > \somepath\file1 cd %dir2% find -type <type> | sort > \somepath\file2 comm <options> file1 file2 |less -S
Note replace $... and #...# with the paths if you don't know how to make variables :)