Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
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.
Regards.

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.batif not %OS%'==Windows_NT' goto 9x
echo.|date>datevar.bat
echo.|time>timevar.batecho set DATEvar=%%5>the.bat
call datevarecho set DAYvar=%%4>the.bat
call datevarecho set TIMEvar=%%4>the.bat
call timevargoto end
:9x
echo.|date>datevar.bat
echo.|time>timevar.batecho set DATEvar=%%4>current.bat
call datevarecho set DAYvar=%%3>current.bat
call datevarecho set TIMEvar=%%3>current.bat
call timevar:end
::**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]
HTH
M2
If at first you don't succeed, you're about average.

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...regards,
Ootsooboo

Control Panel will change the layout, but won't help DOS create the %DATE% var.
M2
If at first you don't succeed, you're about average.

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

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |