dos script to delete 2 days old folders

December 25, 2011 at 23:43:06
Specs: Windows XP

I am taking backup of imp log files in a folder on daily basis. My folder name generated by sysdate, i.e. for today my folder name will be 26-12 , for yesterday 25-12 , and so on..
There are some other folders also which dont have this name format.
Here my requirement is- I want to delete those folders which are 2 days old and having name as mentioned above(i.e. "month-date" / (26-12 for today))..other folder should not delete.
Any help will be highly appricited.
Please reply soon..i will be very thankful to you.


See More: dos script to delete 2 days old folders

Report •

December 26, 2011 at 17:39:41
What is your system date format?

Please come back & tell us if your problem is resolved.

Report •

December 26, 2011 at 22:43:42
Hey, Thanks for your response.

Here is my system date format.

The current date is: Tue 12/27/2011
Enter the new date: (mm-dd-yy)

I want to confirm if it is really so important. Because i have to schedule this script on server.
I am using a backup script, and it is working fine for my local system also.
Sorry, i could not provide you server date format as i am facinf some issue right now.

A quick response will be highly appriciated.
I too have a script but it is not fulfilling my one requirment,
i.e. It is also deleteing all the folders which are not like "month-date".
Please see if you can modify it as per my requiremnt...
cd c:\backup

SET dates=%date:~7,2%
SET /A day =%dates%
SET /A month=%date:~4,2%
SET today=%month%-%day%

SET /A day =%dates% - 1
SET yesterday=%month%-%day%

for /d %%i in (*) do (

IF /I %%i equ %today% (
echo "Today"
) ELSE IF /I %%i equ %yesterday% (
echo "Yesterday"
) ELSE (
rmdir /q /s "%%i"

Report •

December 28, 2011 at 17:04:32
Twice you have quoted your folder names as being "Month-Date" then you show examples such as 26-12 which is "Date-Month". Please confirm which format you are using..........

Please come back & tell us if your problem is resolved.

Report •
Related Solutions

Ask Question