Creating a folder for today's Date

  • Thread starter Thread starter Micheal
  • Start date Start 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
 
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"
 
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
 
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
 
Back
Top