|
Answer» Hi
Newbie, its late and I'm tired. Need help. In a batch file: I wanna make a directory with the NAME = "date and hour" (yyyy-mm-dd-hour). For example:
2009-02-01-04
Don't know how to get the hour in a variable (with the date).
In xp pro.Hmm...
This spits out the date and time:
CODE: [Select]@echo off time /t >> T.txt date /t >> T.txt exit It makes it into a new file, named T.txt.Mumin - Welcome to the CH forums.
Try this: Code: [Select] @echo off cls set datime=%date%-%time:~0,2%
echo %datime%
Good luckManipulating the date and time environment variables is dependent on your Windows regional settings ... but for the U.S. English DEFAULT settings for Windows XP, you can use: Code: [Select]md "%date:~-4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%" And I guess you would want to substitute the space with a 0 (when the hour is less than 10) like: Code: [Select]set DateHr=%date:~-4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2% md "%DateHr: =0%"Thanks all, that did the trick. Nice response. It's a batch file to make sorting and STUFF easier/quicker managing photos from my camera.
|