Automatically create folder with todays date?

Soldato
Joined
27 Sep 2004
Posts
11,200
Location
The Ledge Beyond The Edge
Hiya,

I am looking for a way in dos to automatically create a folder using todays date as the name?
Its going to sit in a batch file and once its processed some files i want it to move them into an archive folder of todays date, does anyone know how to do it??

Cheers
 
I can think exactly how you do it but the trick is to create a folder using the variable %date% in it... ie backup%date%.zip or MD folder%date%

This and a combination of SyncBack has sorted out my backup problems :)
 
this is how i used to do it in work..

go to REgional Settings / Options (dont have it on this pc) then go to date format, set the seperator to "-" instead of "/"

then in a bat file..

md %date%

it'll be called "19-10-2006"


if you leave the seperator asit was, it'll come out as c:\19\10\2006\ which kinda messes it up a bit, unless you maybe set it as c:\2006\10\19
 
What i have is a batch file with the following in it

set ddmmyy=%date%

md %ddmmyy%

and it tried to create a folder called 19/10/2006 which it doesnt like cause of the / can i cant it to . or just no divider at all??

edit ahhh just seen yer ninja edit, will try that lol

edit again, that worked and it wasn't a ninja edit but someone else sorry lol

thanks for yer help guys :D
 
Last edited:
Yeah sorry

I had a a bat file with the following in it

md %date%

Copy *.txt %date%\*.txt

But to get it will only work if you do what Bledd said and change the date separator in the regional settings to something other than / i used - and it creates my folder dd,mm,yyyy
 
this should work without changing anything :)






create_dated_folder.bat
---------------------------------------
@Echo off
cls

rem OcUK - create dated folder,
rem http://forums.overclockers.co.uk/showthread.php?t=17641153
rem .
rem date in format:
rem 19/10/2006
rem 0123456789 - spacing numbers
rem .
rem %date:~0,2% means start at position 0 and select 2 digits, ie "19"
rem or shuffle it around for different folder formats

set folder=%date:~0,2%_%date:~3,2%_%date:~6,4%

echo making a directory called c:\%folder%

cd c:\
md %folder%

---------------------------------------








.
 
Back
Top Bottom