Creating a folder for today's Date

M

Micheal

I am trying to create a folder for today's date in a
batch file. I am using the command md "%date%". in the
command window it display the flowing, E:\System
State>md "Mon 07/14/2003". However when you view the
folder the folders name is Mon 07. I know this is
because you can not use / in folder names. Is there a
way I can get the the the date to generate with dashes
instead of /? ie. Mon 07-14-2003

Thanks

Micheal
 
P

Phil Robyn

Micheal said:
I am trying to create a folder for today's date in a
batch file. I am using the command md "%date%". in the
command window it display the flowing, E:\System
State>md "Mon 07/14/2003". However when you view the
folder the folders name is Mon 07. I know this is
because you can not use / in folder names. Is there a
way I can get the the the date to generate with dashes
instead of /? ie. Mon 07-14-2003

Thanks

Micheal

C:\cmd>echo md "\%date:/=-%"
md "\Mon 07-14-2003"
 
M

Micheal

Phil ,

You ROCK. Thanks for the help. One of these days I will
learn more coding. Between Cisco and Microsoft changes,
and companies wanting one person to know everything, it
is good to know that there is help out there.

Thank you Phil.

Micheal
 
K

Karl Bernard

Another method that I found somewhere (I can't remember where...)

@REM -----------------> Delim the Date <-----------------
for /F "tokens=1,2,3,4 delims=/ " %%i in ('date /T') do set
daymmddyyyy=%%i_%%j_%%k_%%l

The "FOR /F" reads out the different elements of the date (Day, Month, Day,
Year) and you can mix and match the parms into the variable consist you
like.

See ya,

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top