Making a directory with a date?

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Using Windows XP or Win 2003 Server.
Is there a way to make a batch file that will create a new folder with the
date?

For example, if it were this easy....,
MKDIR %DATE% would make a directory 11-13-2007

Thanks.
 
Unfortunately the author of this page got things somewhat confused.
He wrote that the command should look like so in a batch file:

echo md %%date:~-4,4%%\%%date:~-10,2%%\%%date:~-7,2%%

whereas in "DOS" it should look like so:

echo md %date:~-4,4%\%date:~-10,2%\%date:~-7,2%

There are two problems here:
a) There is no DOS under Windows, only the Command Prompt.
b) The first command is wrong. The second command is correct,
both in a batch file and in a Command Prompt.

You could also use this syntax, giving you a somewhat different result:

echo md "%date:/=%"
 
I use the following script within CMD files in Win2K, WinXP, and Vista to create
folders named in the mmddyyyy format:

for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set mdate=%%A%%B%%C
md %mdate%

I am not the author of this script...all I know is that it works.
 
You must place both lines into a batch file, then run the
batch file. If you still have a proble, post your version
of the batch file here and quote all error messages.
"It does not seem to run" does not tell us a great deal.
 
Yes, that's all there is to it.

To create the command file, create a new text file on your top level folder,
open it and
copy the script contents then paste them into the body of this new file and then
save (using save-as) the file as "CreateDateFolder.cmd", with the quotes. You
should then have a New
Document.txt and a CreateDateFolder.cmd in your folder. You can delete the TXT
file.

If you prefer a batch file, use the BAT file extension instead of CMD.
 
Back
Top