Question: I have a directory with a lot of books in PDF format (around 2GB in size).
While reading I often leave notes and annotations in the files. Occasionally I make a backup on an external hard drive. Since I do not remember which files have been modified since the last backup, I just copy and overwrite the whole thing.
Does Windows check if files with the same name are identical (by content) before overwriting? If not, how would I approach doing exactly this?
Answer:
Robocopy.
Windows cannot differentiate between identical and modified files if you copy using Windows Explorer.
Windows can differentiate between identical and modified files if you copy using Robocopy, which is a file-copy utility included in Windows (Vista, 7, 8.1 and 10).
There’s no need to use third-party tools.
You can save this script as a batch file and re-run it whenever you want to perform a backup:
robocopy /e c:PDFs p:PDFs
- Whenever a PDF file is annotated and the changes are saved, both its Last Modified and Size attributes will change in the source folder, triggering an overwrite of the corresponding file in the destination folder the next time Robocopy is invoked.
- Robocopy compares the Size and Last Modified attributes of all files that exist in both the source and destination. If either attribute is different, then the destination file will be overwritten. Note: these values only need to be different, not necessarily newer or larger; even if a source file has an older Last Modified or smaller Size attribute, the source will still overwrite the destination.
- the /e (or /s) switch isn’t necessary if all of your PDFs are in the root of the folder referenced in the script but if you want to include Subfolders then use /s. If you want to include subfolders and Empty subfolders, then use /e.
- I would assign the backup drive a letter further along in the alphabet, so there’s no risk of another drive being inadvertently assigned the drive letter used in the script, causing the backup to fail at some point in the future. I used P here for PDF.
That simple script is all you need.