1.

Solve : Creating folders using the date?

Answer»

I am trying to figure out how to create new folders in DOS by using a date stamp.

I have tried "mk C:\folder\%date%", but I get a syntax error when doing that. I want the format to be MMDDYYY or MMDDYY doesn't matter.

Help??Try md instead of mkThe md error was just part of the problem. You'll need to parse the date to eliminate the forward slashes (MMDDYYYY).

CODE: [Select]@echo off
for /f "tokens=2-4 delims=/ " %%i in ('date /t') do (
md c:\folder\%%i%%j%%k
)



Any code CONCERNING dates is dependent on your LOCAL settings. You may have to make some minor adjustments to the code.Quote

You'll need to parse the date to eliminate the forward slashes (MMDDYYYY)
Ah right. My format is DD-MM-YY Quote
Ah right. My format is DD-MM-YY

Changing the delimiters and flipping the variables would be what I meant by:

Quote
Any code concerning dates is dependent on your local settings. You may have to make some minor adjustments to the code.

Code: [Select]@echo off
for /f "tokens=2-4 delims=- " %%i in ('date /t') do (
md c:\folder\%%j%%i%%k
)

Many languages have functions for returning singular values for day, month and year regardless of format. Batch code can return the date; the USER has to be aware of the format.



Discussion

No Comment Found