Batch file to delete and copy latest file
Posted on 2008-10-30
Hi, I have configured Acronis to create daily backups based on an orginal image file. The file number increments daily. What has happened is that I ran a script to delete the older files and copy the latest. However the script delete the latest file and left a file that is 3 days old and did the copy based on that file; e.g. I had 12 file labeled hbserver_bkup1.tib to hbserver_bkup12.tib with # 12 having a timestamp of 10/29/2008. However, when I ran the script all the files from 1-12 for delete with the exception of hbserver_bkup9.tib dated 10/26/2008 and said bkup9.tib was copied.
This is the script......where did I go wrong. I'm also new to this:
for /f "skip=1 tokens=* delims= " %%a in ('dir/b /a-d /o-n *.tib') do (
xcopy z:\*.tib /a /y /d /k "i:\Server Backup"