Robocopy - Compare modified file dates?
I tried to create this script which basically displays two sets of folders and its contents (including subfolders), but only copies files that are newer than those that already exist. I tried to do this by writing a vbscript, but it turns out that I need to scan each subfolder and then the content. And then the contents of that subfolder, and so on, and so on.
So I'm wondering if anyone knows if this can be done using Robocopy?
a source to share
In short - yes - it's good and easy with RoboCopy. By default, it will copy modified files anyway and will not copy unchanged files. You just need to add one argument so that it can exclude files where the new destination exists and exists.
RoboCopy's syntax is a bit fancy, so you can read more from here .
You probably want something like this:
RoboCopy.exe %sourceDir% %targetDir%\ *.* /xo
%sourceDir%
- your source directory
%targetDir%
- your target directory
*.*
- files in the source directory to copy
/xo
- exclude the file if the destination already exists and is newer.
[Edit in response to comment]
If you say you want to delete files from the destination directory that no longer exist in the source directory, I believe the switch /purge
does that.
a source to share