I am a novice but trying to create a batch file that reads the folder contents of the source, compares the files to the destination, backs up the matches, and then moves the source files to the destination. I guess in a way the file contents in the source directory works as a mask.
Is there a technique I could use to get this result? I've tried Robocopy
and XCopy
with close but not what I am looking for. XCopy
has an exclude option but that's the opposite of what I need. Any suggestions would be much appreciated.
The set up is like this:
These folders contain this
Parent_folder_new
Folder1 Folder2 Folder3
File1 File1 File1
File2 File2 File2
File3 File3 File3
I have new files to replace the old:
Parent_folder_old
Folder1 Folder2 Folder3
File2 File1 File1
File3 File3
Before the source files overwrite the destination ones I need to backup only the soon-to-be overwritten files.
I've tried an if statement but I don't know where to go after that
Set folder[1]=folder1
Set folder[2]=folder2
Set folder[3]=folder3
for F "tokens=2 delims==" %%f in ('set folder[') do (
if Parent_folder_new\%%f==Parent_folder_old\%%f
::copy results of if statement to Parent_folder_backup\%%f
)
I hope this clears up somewhat of what I'm trying to do.