Using dates in batch files to rename files with yesterday's date

I have a script that gives me today's date in the following format 20081106. I need to change the script so that I get the date in the following format 081106.
Also, I would like another variance of the script to get yesterday's date.
@echo on
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set Date=%%c%%a%%b
echo %date%

Open in new window

nsc_techAsked:
Who is Participating?
 
wwnosalConnect With a Mentor Commented:
And this should solve your second problem:
http://www.robvanderwoude.com/datetiment.html#Yesterday
0
 
wwnosalConnect With a Mentor Commented:
This solves your firs problem:
@echo on
for /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do set Date=%%c%%a%%b
echo %date:~-6%

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.