batch script to delete file by oldest timesta

January 7, 2011 at 15:47:32
Specs: Windows XP Pro
I have a backup solution that consists of a hardware raid 1 acting as a central server (country_store) mapped as drive "z" to a remote pc (Reg3). I used FBackup4 to write a disk image to drive z (\\country_store\Reg3_backup) daily. Reg3 is WinXP sp3 and country_store is WinXP sp2.

I would like a batch file to compare timestamps and leave the last two disk images indefinitely until another image is written to the folder.
I started with dates as in;
FORFILES /p E:\FBackup4 /d -2 /m * /c "cmd /c del @file"
but we have frequent power failures here, potentially the server could go down over the weekend and the backups would be deleted prior to another image being written. Reg3 contains a database entailing months of work so 100% backup is mandatory

See More: batch script to delete file by oldest timesta

Report •

January 10, 2011 at 14:59:10
i m not exactly sure what you want and how it will be accomplished.
May be below will help.
In a batch file below line will extract the date and time info of all the fles and save as variable %%a
for /f %%a in ('dir /b') do echo %%~ta

now, below lines will give you currnt date and time.

Set MM=%date:~4,2%
Set DD=%date:~7,2%
Set YYYY=%date:~-4%

echo %YYYY%-%MM%-%DD%

Now, you can compare these, try some logic and it should work

Subhash Chandra.

Report •
Related Solutions

Ask Question