please explain me this

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Mohammad_Dos
Posts: 84
Joined: 08 Sep 2010 10:25
Location: Iran,Kashan
Contact:

please explain me this

#1 Post by Mohammad_Dos » 01 Dec 2010 10:43

Hi, this is for make a directory with name of date:


Set MM=%date:~4,2%
Set DD=%date:~7,2%
Set YYYY=%date:~-4%
md %YYYY%-%MM%-%DD%


please explain me this


%date:~4,2% ?!!!!!!
%date:~7,2% ???????!!!!!!
%date:~-4% ؟؟؟؟؟؟!!!!

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: please explain me this

#2 Post by aGerman » 01 Dec 2010 13:08

This method is not safe.
Check the output of

Code: Select all

echo %date%

If you find something like ...
Wed 12/01/2010

... it would work for you.

The next 2 characters after the 4th is the month.
The next 2 characters after the 7th is the day.
The last 4 characters is the year.

For additional informations type SET /? to the command prompt.

Regards
aGerman

Post Reply