Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
I have backup folder Backup_2009_15_07 ,Backup_2009_16_07 and Backup_2009_10_08. I want to know batch file commands which will deletes all previous month back up folders like Backup_2009_15_07 ,Backup_2009_16_07 except Backup_2009_10_08 from folder C:\Batch\ARCHIVE\FINAL
Name: dtech10 Date: August 12, 2009 at 12:25:58 Pacific
Reply:
Hi
In order to help you we need to know your date format in order to idenify the current month. Type this at the Dos prompt and post it back.
echo %Date%
0
Response Number 2
Name: hrshelke Date: August 12, 2009 at 13:23:01 Pacific
Reply:
C:\>date The current date is: Wed 08/12/2009 Enter the new date: (mm-dd-yy)
I am creating backup folder by folloing code set Day=%Date:~7,2% set Mth=%Date:~4,2% set Yr=%Date:~10,4%
c:\Batch\ARCHIVE\FINAL\BACK_%Yr%_%Mth%_%Day%
0
Response Number 3
Name: OtheHill Date: August 12, 2009 at 13:25:02 Pacific
Reply:
Not to throw water on your fire but if you only have a few why bother? Just manually delete. Do you verify your backups?
0
Response Number 4
Name: hrshelke Date: August 12, 2009 at 13:28:43 Pacific
Reply:
The above is example with few folders. I am going to have lots of folders . Just i want code which deletes previous month folder and keep this month under C:\Batch\ARCHIVE\FINAL.
0
Response Number 5
Name: dtech10 Date: August 12, 2009 at 14:34:19 Pacific
Reply:
Hi Hrshelke
Delete the /s if you don't want confirmation, but it's best to leave it for testing. I take it that there only last months backup files in the %Dir% directory.
@echo off set Mth=%Date:~4,2% set DIR=C:\Batch\ARCHIVE\FINAL for /f "tokens=1-4 delims=_" %%a in ('dir /b /ad %Dir%') do ( if %%d LSS %Mth% (rd /s %Dir%\%%a_%%b_%%c_%%d) )
0
Response Number 6
Name: hrshelke Date: August 12, 2009 at 14:48:55 Pacific
Reply:
Thanks dtech10.
The code is working really fine.
0
Response Number 7
Name: dtech10 Date: August 13, 2009 at 07:57:03 Pacific
Reply:
Hi Hrshelke
Forgot to cater for year end.
@echo off set Mth=%Date:~3,2% set DIR=g:\@Temp\BATCH\Batch\ARCHIVE\FINAL for /f "tokens=1-4 delims=_" %%a in ('dir /b /ad %Dir%') do ( if %Mth% EQU 01 (if %%d EQU 12 (rd /s %Dir%\%%a_%%b_%%c_12)) if %%d LSS %Mth% (rd /s %Dir%\%%a_%%b_%%c_%%d) )
Summary: i had to do a system restore, not the non destructive system recovery but the "system recovery-no format" one this backs up windows and various applications to a folder/directory, i've now got and upd...
Summary: I'm on an XP system so why should I have a whole group of Nt Uninstall files? Only M$ can give you a more authoritative answer. Thus, my question is still, what would be the problem with deleting th...
Summary: Hi, whenever i go to delete or edit this folder, it comes up saying Cannot delete file: Cannot read from the source file or disk anyone know how to sort it? ta ...