Home / Microsoft / Microsoft DOS / Create a directory with today's date and delete one with yesterday's
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 2 [3]  All - (Bottom) Print
Author Topic: Create a directory with today's date and delete one with yesterday's  (Read 6246 times)
ALAN_BR
Hopeful



Thanked: 5
Posts: 346


« Reply #30 on: June 01, 2009, 07:04:46 AM »

An infinitely simpler system would be to NOT delete a folder with a name matching Yesterdays date.
Instead delete ALL folders whose name does not match today's date.

Or even simpler, delete all folders that were not created/modified today.

That not only gets rid of yesterday's folder, but on Monday it will get rid of Friday's folder (assuming a Monday to Friday working week).

The only requirement is that these folders must be sub-folders within one one common parent folder (and this parent never deleted).

Regards
Alan
IP logged

Acer Laptop TravelMate 244LM. 1.25 GB Ram + 160 GB HDD. C:\ = 20 GB.
Windows XP Home Edition with SP3; Acronis T.I. 11.0 (build*8,101);
Protection ESET NOD32 v 2.7 Antivirus plus Comodo Firewall 3.5.
PerfectDisk 2008 v 9.0.0.64; Partition Wizard
EasyBcd Dual Boot, Default XP, W7 if I really have to
ronchong
Newbie



Posts: 1

Experience: Beginner
OS: Unknown

« Reply #31 on: November 30, 2011, 07:09:43 PM »

SET dwMONTH=%DATE:~4,2%
SET /A dwDAY=%DATE:~7,2%
SET dwYEAR=%DATE:~10,4%
SET dwDate=%dwMONTH%/%dwDAY%/%dwYEAR%
for /F "tokens=1" %%a IN (YesterdayDate.txt) DO set yest=%%a
@echo %yest%
forfiles /p "." /C "cmd /c if @fdate==%yest% rd /q /s @fname" > "DeleteDirectoryLog%DATE:~4,2%_%DATE:~7,2%_%DATE:~10,4%.txt"
@echo %dwDATE% > "YesterdayDate.txt"
IP logged
ALAN_BR
Hopeful



Thanked: 5
Posts: 346


« Reply #32 on: December 01, 2011, 01:28:14 AM »

After almost 3 years I think the O.P. has now giving up waiting   :)
IP logged

Acer Laptop TravelMate 244LM. 1.25 GB Ram + 160 GB HDD. C:\ = 20 GB.
Windows XP Home Edition with SP3; Acronis T.I. 11.0 (build*8,101);
Protection ESET NOD32 v 2.7 Antivirus plus Comodo Firewall 3.5.
PerfectDisk 2008 v 9.0.0.64; Partition Wizard
EasyBcd Dual Boot, Default XP, W7 if I really have to
Pages: 1 2 [3]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / Create a directory with today's date and delete one with yesterday's « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.129 seconds with 19 queries.