batch file

A

Aaron

FOR /f "tokens=1-3 delims=/" %%a in ('date /t') do set vl=%%a%%b%%c
md "%vl%"

this would create a folder named Tue 05042004
how can i get rid of the "Tue " part?
i want the folder to be just 05042004

Thanks
 
J

Jim Hughes

Note the space after the slash in delims=
tokens 1-4 instead of 1-3
b,c,d instead of a,b,c

FOR /f "tokens=1-4 delims=/ " %%a in ('date /t') do set vl=%%b%%c%%d
md %vl%


I would probably reverse the order and use =%%d%%c%%b yearmonthday so that
sorting works better.
 
G

guard

FOR /f "tokens=1-3 delims=/" %%a in ('date /t') do set vl=%%a%%b%%c
md "%vl%"

this would create a folder named Tue 05042004
how can i get rid of the "Tue " part?
i want the folder to be just 05042004

Try the Mount/\Command GetLogDate, part of the FREE
Advanced Command Library (ntlib.cmd). GetLogDate
CONSISTENTLY returns yyyymmdd and saves this value
in variable %#LogDate%. For details, see

(http://TheSystemGuard.com/MtCmds/GetValue/GetLogDate.htm)
(http://ntlib.com)

*******

In your specific case, the syntax would be:

%.GetLogDate% %.Silent%
MD %#LogDate:~4,4%%#LogDate:~0,4%

*******

-tsg

/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(http://TheSystemGuard.com/default.asp#MasterCommandList)
 

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

Similar Threads

cmd help 1
search substring in string 4
search substring in string 1
how to parser the config file 2
HELP!! How to delete old folders?? 3
Please explain 4
Reading from a File 1
SET command adds quotation marks 2

Top