Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minus 1 day from current date in batch file?

Status
Not open for further replies.

dfwcharles

Technical User
Apr 10, 2002
36
0
0
US
I'm using a batch file to delete files based on the file name. The file name is formatted like this: "log07-14-2004.txt"
I need a way to take the current date in DOS and minus it by one day. Here's what i got so far:

@echo on
set currdate=%date%
set mm=%currdate:~4,2%
set dd=%currdate:~7,2%
set yyyy=%currdate:~10,4%

del C:\testlogs\log%mm%-%dd%-%yyyy%.txt

this works for the current day, but i want to run this everyday to delete the file from the previous day. Is there a way to minus one day from the date?

Thanks
 
Use VBScript. There are plenty of FAQ's about things like this in the VBScript forum. Besides, .bat's are fine for 98, but you can do so much more with scripts that .bat's.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top