Link to home
Start Free TrialLog in
Avatar of Ryan Bennett
Ryan BennettFlag for United States of America

asked on

Create a folder using current date as the name...

This question has probably been ask a thousand times but here goes one more time...

 I would to use a bat file to create a folder that uses the current date as the name of the folder, IE. something like or close to "5-2-2005". I tried using md "%date%", but I get a folder called "Mon 05" containing a subfolder called "02" and containing yet another subfolder called "2005". I know very little about DOS scripting so I have searched high and low & have come up with nothing. So, once again I will ask for your help.

 Thanks,
RBennett
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To explain a little further:

REM set the variable MM to the value of the %date% variable, but only take
REM the two characters starting at the 4th character (and remember the first
REM character is character 0)
Set MM=%date:~4,2%

REM Like above, only take the 2 characters starting at the 7th character
Set DD=%date:~7,2%

REM Like above, only take the last 4 (-4) characters from %date%
Set YYYY=%date:~-4%
MD %MM%-%DD%-%YYYY%
Avatar of Ryan Bennett

ASKER

I guess it helps if you know what you're doing. Exactly what I've been trying to do.

 Thanks a bunch,
RBennett