Sunday, January 01, 2006

Create a folder based on today's date.

Though this can be applied in many ways, the WindowsNT/2000 Command Prompt has some powerful differences over the old MS-DOS Batch Language. the FOR command is just one difference. The delimiters specified and the order of the variables (%a, %b, %c) will depend on your localized settings. By default the following should create a folder called '20031129' (based on November 29th, 2003).

FOR /F "tokens=2,3,4 delims=/ " %a in ('date /t') do mkdir %c%a%b

This could be applied to a daily backup procedure using PKZIP from a command-line.

2 comments:

Cameron Stevens said...

I found a better way:

MKDIR %DATE:~6,4%%DATE:~3,2%%DATE:~0,2%

Though the same concerns are raised, the splicing is completely dependant on your localisation.

Espen said...

Excellent! This solved my problem on the spot. Thanks.

There is no individual ownership when you are part of a team, it's the sum of the parts that makes you the RESILIENT team you need to be.