Lets say you want to have a .bat file that zips up a directory into an archive with the current date and time as part of the name, for example, Code_2008-10-14_2257.zip
In a windows console(CMD), the following command helps you get what you need
@echo off For /f "tokens=2-4 delims=/ " %a in ('date /t') do (set mydate=%c-%a-%b) For /f "tokens=1-2 delims=/:" %a in ('time /t') do (set mytime=%a-%b) echo %mydate%_%mytime% @echo on echo "Testing 123" >> "testFile_%mydate%_%mytime%.txt"
This would output the filename appended with the desired time format.