Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jan 29 '10 at 7:44

This question came from our site for professional and enthusiast programmers.

7 Answers 7

up vote 6 down vote accepted

Use WinDiff. It comes with Visual Studio and Platform SDK and can be downloaded separately. It's mainly to compare files, but it also allows you to recursively compare folders.

share|improve this answer

In cygwin

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.

I used -S so less doesn't wrap and you can see the columns clearly.

options

  • -23 shows what is unique to $dir1 in first column, suppresses other two columns
  • -13 shows what is unique to $dir2 in second column, suppresses other two columns
  • -12 shows every thing the same between $dir1 and $dir2, suppresses first two columns

type

f for just files d for just directory or use type twice with both or remove type altogether for everything.

In CMD

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 :)

share|improve this answer
    
It would be nice to have something that compares many directory's and then gives what DIRs have the most in common and what they don't have among the many (of course you could do some bash tricks with the above). Will try WinDiff –  sabgenton Jan 21 '13 at 6:51
    
I don't know if it's just me but PS compare-object $d1 $d2 was slow for me. –  sabgenton Jan 21 '13 at 6:53

FreeCommander does this quickly. Pick folder on right, pick folder on left, compare. It's a handy utility.

share|improve this answer

If you are looking for a manual process and have visual studio installed, then you can use windiff.exe to show the differences.

share|improve this answer

In PowerShell:

$d1 = get-childitem -path $dir1 -recurse 
$d2 = get-childitem -path $dir2 -recurse 
compare-object $d1 $d2 
share|improve this answer
    
I did this between a dir on my USB card and my local computer. 10 mins later, still waiting... –  jcollum Jun 5 '11 at 17:38

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

output

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
share|improve this answer

I tend to use PathSync

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.