0

I have the following scenario

Folder 1
 -Folder a
      -File1.txt
      -Img1.png
 -Folder b
      -File2.txt
      -Img2.png

Folder 2
 -Folder a
      -File1.txt (File 1 modified)
      -Img1.png   (No change)
 -Folder b
      -File3.txt (New file added)
      -Img2.png  (no change)

Basically I want the output folder to have the following files(modified or added in the original structure, with the structure preserved)

OutputFolder
  -Folder a
       -File1.txt
  -Folder b 
       -File3.txt

I am trying to use the Beyond Compare Command line to do this, but I cant find any arguments to suit and I dont want to loop over all files(too many files) for changes manually or use SVN. Any other tool/script I could use to achieve this?

Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103

1 Answers1

1

if the changes are only in the "Folder 2"-Structure and Folder 1 will always be untuched, i got it to work with:

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "TOKENS=2,* DELIMS=  " %%A IN ('ROBOCOPY "Folder 2" "Folder 1" /MIR /XX /NDL /NJH /NJS /L') DO (
  SET tmpFolder=%%~dpB
  SET tmpFolder=!tmpFolder:Folder 2=OutputFolder!
  XCOPY "%%~B" "!tmpFolder!" /E /F /H /R /C
)
ENDLOCAL

Robocopy will only list the changes between folder 2 and folder 1, the for loop will copy the files to the "outputfolder", keeping the folder-structure

BaBa
  • 337
  • 2
  • 10
  • Thanks! Yes assumption about folders is right, but it doesn't seem to be working for me. – Vrashabh Irde Nov 11 '14 at 07:00
  • Any (Error) Message? How's your original Folderstructure? – BaBa Nov 11 '14 at 08:52
  • Ahhh... hahaha... i forgot to remove the `/L`-Param from `XCOPY`. So `XCOPY` will atm only list, but not copy xD Sorry. I removed it from the original-post. – BaBa Nov 11 '14 at 08:54
  • Still no (error)-message or your originalfolderstructure... how's your exact code? – BaBa Nov 12 '14 at 05:42
  • Nope, same folder structure as above, ill debug with messages and get back! Thanks! – Vrashabh Irde Nov 12 '14 at 05:43
  • Does not seem to be going into the for loop at all, have all the folder structures correct. It just skips over. If I do only robocpy line on cmd, it prints the differences – Vrashabh Irde Nov 12 '14 at 05:47
  • Please add "LOG:Robocopylog" after the /NJH /NJS /L-Switch: `/NJH /NJS /L /LOG:Robocopy.log` – BaBa Nov 12 '14 at 06:09
  • It prints correctly - the log - `Newer 9 C:\Users\administrator\Desktop\Folder2\A\1.txt New File 0 C:\Users\administrator\Desktop\Folder2\B\4.txt` – Vrashabh Irde Nov 12 '14 at 06:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/64762/discussion-between-slartibartfast-and-baba). – Vrashabh Irde Nov 12 '14 at 07:09
  • so there's no space between "folder" and "2". Have you changed the code to fit that? Are you sure, that the char after "delims=" is a tab-Character? – BaBa Nov 12 '14 at 07:44