I was trying to compare files in 2 folders and copy those new and updated files to a diff folder, for example:
newFolder has
a\aa.txt (new folder and new file)
b\aa.txt
b\ab.exe (modified)
b\ac.config (new file)
aa.txt (modified)
ab.exe (new file)
ac.config
oldFolder has
b\aa.txt
b\ab.exe
aa.txt
ac.config
In this case, what I expect in diff folder should be:
diffFolder
a\aa.txt
b\ab.exe
b\ac.config
aa.txt
ab.exe
So far I have been searching on google and trying different approaches, but still cannot achieve this.
I have get the files list includes files needed to be copied along with their path by using
xcopy /edyl "newFolder\*" "oldFolder"
and was trying using
for /f %%F in ('xcopy /e /dyl "new\*" "old"') do @xcopy %%F diff /e
this messes up diffFolder
also tried
for /f %%F in ('xcopy /e /dyl "new\*" "old"') do @robocopy new diff %%F /e
this only create directories in diffFolder but not copy files, gave me error: invalid parameter #3 :"newFolder\a\aa.txt"
for /f %%F in ('xcopy /e /dyl "new\*" "old"') do @copy "%%F" "diff" >nul
only copy files not create directories.
I was also trying to use powershell but result the same with @copy.
Any one can help me on this specific issue?
Thanks in advance!