Moving old files before using sync folders command

Discuss and share scripts and script files...
Post Reply
Colin
Posts: 1
Joined: 13 Aug 2021 04:15

Moving old files before using sync folders command

Post by Colin »

Hi

I am seeking a way to archive the files & folders that would normally be overwritten or deleted by the sync folders command.

I normally use sync folders from C:\Jobs to D:\Jobs and get the expected behaviour, but would like a script that can be run beforehand that would identify the files that sync would overwrite or delete and copy them to another folder.

For example if a change in C:\Jobs since last synchronization was deleting the file C:\Jobs\Welding\specs.pdf then the "archive" script would copy the file (now unique to the D: drive) to D:\Archive\2021-08-15\Welding\specs.pdf before the sync command deleted it from the D:\Jobs... folder.
Likewise if the following day a change was that the file "bills.xls" in the C:\Jobs\Finance\ folder was edited then the older one (existing on the D: drive) would be copied to D:\Archive\2021-08-16\Finance\bills.xls before being overwritten during the sync.

Conceptually the overall result (after the sync command) would be the same whether the obsolete file is Copied or Moved to the archive folder, but I guess it's existence wouldn't feature in the sync log file if it was Moved by the "archive" script before the sync was run.

Is this something anyone has attempted before?

Regards, Colin

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Moving old files before using sync folders command

Post by highend »

That isn't too difficult...

If you need more parameters than "missing in $src" and "modified date in $src is newer that in $dst" you need to add them yourself

Adapt the paths in the script and make sure they exist^^
Copy files into archive before sync.xys
(2.31 KiB) Downloaded 92 times
One of my scripts helped you out? Please donate via Paypal

Post Reply