How to make zip files and folders with a formatted date and time stamp as the folder name in a DOS batch file automatically
We have a help rendition system internally, where all we writers do is create the source files needed to make CHM files (HHK, HHC, HHP, HTML), zip up the HTML source in a certain way with a certain file name, and submit it using a webform. Out of that rendition engine we can get CHM, JavaHelp,WinHelp, NetHelp, or our internally-created cross-platform help called Browser Help. Browser Help is the system that works with BMC
Performance Manager and I've posted before about how to create those help systems automatically.
Since I needed to render several help systems at once, meaning I had to make multiple zip files containing the right content with the right zip file name, and I dislike tedious repetitive tasks, but somehow I like the tedium of testing and using scripts, I used DOS batch files to do the file creation and name formatting for me.
Today's tip is how to make folders with a date and time stamp as the folder name. Our rendition engine likes its zip files with a certain naming convention. As an added bonus, this routine works before and after ten in the morning. Silly DOS, it doesn't put a leading zero in unless you tell it to. Here's how to tell DOS to put in the leading zero if the current time is prior to 10:00am.
REM Create sub directory called \yymmdd_hhmmss
REM where yymmdd_hhmmss is a date_time stamp like 030902_134200
REM Since there is no leading zero for times before 10 am, have to put in
REM a zero when this is run before 10 am.
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
A Command-line reference A-Z that contains all the reference information for DOS command-line parameters is available on the Microsoft site.