Discussion Locked

Making a Directory with DOS

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I use MD or MKDIR to make a directory with a changable directory name. An example would be MKDIR c:My directory%DATE%. Is this possible? I would like to put this into a batch file to excute on a scheduled basis and create a new directory name each time it is run.

Thanks for your help.

10 replies

by mike mullins

You sure can. You should start off by formating the date to display in the format of your choice.
1. Open the region and Language Options in the Control Panel.
2. On the Regional Options Tab, under Standards and formats, click customize and change the date display to the format you want for your file structure.
3. In your batch file issue the md %date% command.
4. Remember to issue a cd\ command when you start and a cd C:\my directory command
before you make you're directory. This will put you in the proper place to create your new directory.

Good Luck,
Mike

by mark

I played with this a little and the problem is that the variable %date% uses "/" for a separator. So what you end up with is a 3 level directory. Like WED 10/ subfolder 22/ subfolder 03. Changing the separator in regional settings did fix it after starting a new DOS box. I used a "." for the separator and used the command {md mydir "%date%"} without the {}. The resulting directory was {mydir Wed 22.10.2003}. Should work just as well using the separator "-". But you can
not use "/" for your date separator.

by otl

Normally I use the format YYYYMMDD for files, thus in windows or dos the newest file/folder is at the end of the list and they are all in order of the creation date.

This discussion is closed to new replies.