Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It appears I was unable to save the scripts I used for converting some Subversion repos to Mercurial ones, more specifically the filemaps.

How can I get diffs between two directories (added/removed directories, files, etc.) with the results provided in a text file?

share|improve this question
DIR /b /s [subversion_directory] > svndir.txt & DIR /b /s [mercurial_directory] > hgdir.txt & [your_diff_tool] svndir.txt hgdir.txt – zb226 Aug 31 '12 at 2:16
How does that print the differences? Lets say there is a difference, everything after that will be wrong (even if it should be marked as same) – soandos Aug 31 '12 at 2:51
@zb226 -- I'm thinking both must be sorted the same – Daniel R Hicks Aug 31 '12 at 3:41
@DanH: You're correct, /o:n for sorting should be added to both dir commands. – zb226 Aug 31 '12 at 8:33
@zb226 - Would you mind converting these comments to an actual answer? I did that with KDiff3 and it partly did the trick (I still had to format it the way it should), so I can accept it. Thanks! – Isxek Aug 31 '12 at 14:09
up vote 3 down vote accepted

Using a full-fledged diff tool like diffmerge or kdiff3 (both free) you can easily check the differences by comparing the output files of the following batch file. As it is, you need to provide the two directories as arguments, but you may as well set those directly in the SET dir... lines - e.g. SET dir1=c:\svn and SET dir2=c:\hg. The script removes the path prefix from the filenames which would otherwise differ on all lines.

SetLocal EnableDelayedExpansion
SET dir1=%1
SET dir2=%2
ECHO. 2>dir1.txt
ECHO. 2>dir2.txt
FOR /f "tokens=*" %%F IN ('DIR /s /b /o:n %dir1%') DO ( 
    SET tmp=%%F
    ECHO !tmp:%dir1%\=! >> dir1.txt
FOR /f "tokens=*" %%F IN ('DIR /s /b /o:n %dir2%') DO ( 
    SET tmp=%%F
    ECHO !tmp:%dir2%\=! >> dir2.txt

Then just diff the two output files dir1.txt and dir2.txt:

kdiff3 dir1.txt dir2.txt
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .