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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATE NEW FOLDER BATCH FILE-YESTERDAYS DATE 1

Status
Not open for further replies.

dilworth

Technical User
May 29, 2002
59
GB
Is it possible to amend the following code that creates a folder with today's date to create a folder name as Yesterdays Date:

@echo off
Set CURRDATE=%TEMP%\CURRDATE.TMP
Set CURRTIME=%TEMP%\CURRTIME.TMP

DATE /T > %CURRDATE%
TIME /T > %CURRTIME%

Set PARSEARG="eol=; tokens=1,2,3,4* delims=/, "
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET YYYY=%%k%
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET MM=%%j%
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET DD=%%i%

Set PARSEARG="eol=; tokens=1,2,3* delims=:, "
For /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMM=%%i%%j%%k

Set NOW=%DD%.%MM%.%YYYY%

MD C:NEW FOLDER"\%NOW%

GoTo END

Any suggestions appreciated.
 
The short answer is yes. But you would have to write a program to generate the parameter.

Rather a lot of work. How about just setting the system clock back during the run?
 
What you have is kind of messy; for example this is not used at all:

Set PARSEARG="eol=; tokens=1,2,3* delims=:, "
For /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMM=%%i%%j%%k

Formally, you would also have to consider outlying values. For example, what do you do on the first day of any month? (Obviously you would have to reset the Month value as well as the Day value, and unfortunately Months do not have the same number of days). And what would happen on the first day of a new year?

For anything other than the first day of any month, add a replacement table prior to your MD command:

IF %DD%==02 set DD=01
IF %DD%==03 set DD=02
...etc. for 31 entries

You could do a seperate parsing table for any DD=01 entry and reset the MM value as well.



 
Thanks for the suggestions-I have added the replacement table but it still creates a folder based on todays date-does the following need to be deleted:

Set PARSEARG="eol=; tokens=1,2,3* delims=:, "
For /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMM=%%i%%j%%k

Thanks.
 
Not really.

It is more likely the parsing table is incorrect:

Try:
IF %DD%==2 set DD=1
IF %DD%==3 set DD=2


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top