Creating a folder/file name based on a date time stamp in NT Shell Script (Batch)
for /F "tokens=2,3,4 delims=/ " %%i in ('date /t') do set datetimefolder=%%k%%i%%j
for /F "tokens=1,2,3 delims=: " %%i in ('time /t') do set datetimefolder=%datetimefolder%_%%i%%j%%k
echo DateTimeFolder=%datetimefolder%
will output something like:
20060516_1216PM
Comments
- Anonymous
January 01, 2003
I prefer: for /F "tokens=1,2,3,4,5,6,7* delims=.:^/^ " %%i in ("%date%.%time%") do ( SET _Timestamp=%%l%%j%%k%%m%%n%%o REM pad hour if single digit if "%%m" neq "" if %%m LSS 10 SET _Timestamp=%%l%%j%%k0%%m%%n%%o) -adrian hains