get date command?

April 28, 2005 at 01:39:25
Specs: Dos, n/a


I am trying to write a script/batch file which creates a folder named with the current days date... I am currently using other commands like md %username% which creates a folder after the persons username. Unfortuantely the command md %date% or get_date does not work in Dos...

Any help would be much appreciated.


See More: get date command?

Report •

April 28, 2005 at 03:00:03

Hi Wolf,

Yeah, there is no %date% built into DOS, so you need to get the date into a var.

You can use this batch to set DAY DATE & TIME vars:

@echo off > quit.bat

if not %OS%'==Windows_NT' goto 9x


echo set DATEvar=%%5>the.bat
call datevar

echo set DAYvar=%%4>the.bat
call datevar

echo set TIMEvar=%%4>the.bat
call timevar

goto end



echo set DATEvar=%%4>current.bat
call datevar

echo set DAYvar=%%3>current.bat
call datevar

echo set TIMEvar=%%3>current.bat
call timevar


This sucess of this batch will depend on the version, the language and the regional / layout of the DATE & TIME.

Using a var to name a file or directory will fail if the var contains chars not allowed in file / directory names.

[/\.;; etc]



If at first you don't succeed, you're about average.

Report •

April 28, 2005 at 04:53:14

This porblem has a very simple solution.
Go to Control panel/Reginal settings.
go to Date tab.
change the delimiter to - instead of '/' that is set as default.
Apply the changes.
then perform "md%DATE%" which will succeed as "26-05-05" as folder name...


Report •

April 28, 2005 at 05:04:35

Control Panel will change the layout, but won't help DOS create the %DATE% var.


If at first you don't succeed, you're about average.

Report •

Related Solutions

April 28, 2005 at 05:20:58

Hi both,

Thanks for your help and quick responses. M2, the resolution that Ootsooboo gave does indeed work like a dream! (thanks Ootsooboo)

Thanks :-)

Report •

Ask Question