One common tool I need in scripts is the ability to time/date stamp a file. The example below shows a simple method for adding time and/or date information to the end of a log file:
Echo [-] Echo [+] Set Date/Time Variables
Echo [-] Echo.
if “%time:~0,1%”==” ” set hour=0%hour:~1,1%
echo Here’s a sample date stamped file: logfilename-%yyyy%-%mm%-%dd%.log
echo Here’s a sample time stamped file: logfilename-%hour%%min%%sec%.log
One cool thing about this method is that it checks for times before 10am. If the hour is not two digits a zero is added. This helps with sorting as all of your filenames will be the same length/format.