I would like to set up a rule in Windows 8.1 to copy a certain file to another location whenever it changes. How can I accomplish this?
2 Answers
Create a batch file with content like this:
robocopy.exe C:\sourceDir C:\TargetDir FileName.txt /MON:1
then run the batch file whenever you log on with your user, there are several ways to do that.
The drawback here is that while this process is running in the background, it is checking for changes to your file only once every minute. So in the worst case you will not having a current backup for 59 seconds.
If you need a more "real-time" copy, you can use the Windows feature FileSystemWatcher, which you have to use from a script or program, e.g. a PowerShell script , but that is a bit more complicated than a one-line batch file.
-
Sorry for late reply, is it possible to have different names for source and destination files? Jun 3, 2015 at 10:50
-
1@FredrikP - Using the first method with Robocopy, No, it uses the source file name as the destination name. If you write your own solution using FileSystemWatcher, you can alter the names. Jun 3, 2015 at 10:57
You can use robocopy for this with the following parameters:
/MON:n :: MONitor source; run again when more than n changes seen
/MOT:m :: MOnitor source; run again in m minutes Time, if changed