Batch file to delete history in destination
Posted on 2015-01-20
I have a batch file that copies bunch of files like Abc.bak ,xyz.bak etc to a different server. I want that batch file to also clean up history in destination folder. It has to delete the files in destination which are older than 3 days. However the catch here is it has to delete only the older files that successfully were copied into destination. Let me explain it better in examples so Day 1 Abc.bak & xyz.bak files were successfully copied to destination and destination folder doesn’t contain Abc.bak & xyz.bak files that Are 3 days old so script doesn’t delete any files. Day 2 Script copies Abc.bak & xyz.bak files and it doesn’t delete any files , Day3 it does the same . On day 4 because of some issue script was able to copy only abc.bak file & it doesn’t copy xyz.bak file. So script should only delete abc.bak file that is older than 3 days and it should not delete xyz.bak file even though it is older than 3 days because script did not copy current days xyz.bak file to destination. Is this possible?
I know it’s confusing but please let me know if you need further explanation