Just Write Click

Technical writing with Continuous Integration and docs-as-code

  • JustWriteClick
  • Contact
  • Books by Anne Gentle
  • Introducing Docs Like Code
You are here: Home / talk.bmc / MS-DOS tips for time and date stamps

May 25, 2006 by annegentle

MS-DOS tips for time and date stamps

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


set hh=%time:~0,2%

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%

set yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%

md h:\%yymmdd_hhmmss%

A Command-line reference A-Z that contains all the reference information for DOS command-line parameters is available on the Microsoft site.

Edited to add: Note that this script does not work for times between midnight and 1:00 am.

Related

Filed Under: talk.bmc Tagged With: date, DOS, time

More reading

Bubble graph showing sources of developer support data

I’ve been thinking a lot about developer support at Cisco recently, especially for the way the world works today with multiple cloud providers. This post is a re-publish of my talk from over five years ago, but the techniques and tools for listening and helping others are still true today. At Rackspace, we watched several […]

Cisco DevNet is our developer program for outreach, education, and tools for developers at Cisco. From the beginning, the team has had a vision for how to run a developer program. Customers are first, and the team implements what Cisco customers need for automation, configuration, and deployment of our various offerings. Plus, the DevNet team […]

I had a great talk with Ellis Pratt of Cherryleaf Technical Writing consulting last week. Here are the show notes, full of links to all the topics we covered. Podcasts are great fun to listen to and participate in, if a bit nerve-wracking to think on your feet and make sure you answer questions succinctly […]

At the beginning of this year, I worked hard to summarize my thoughts on API documentation, continuous publishing, and technical accuracy for developer documentation. The result is an article on InfoQ.com, edited by Deepak Nadig, who also was forward-thinking in having me speak to a few teams at Intuit about API documentation coupled with code. Always […]

Recently on Just Write Click

  • A Flight of Static Site Generators: Sampling the Best for Documentation
  • Try a GPT about “Docs Like Code” to ask questions
  • Discipline and Diplomacy: Docs in the Open
  • Let’s Find Out: When Do Static Site Generators Do Rendering?
  • GitHub for Managing Tech Docs

Just Write Click in your Inbox

Enter your email address to subscribe to Just Write Click and receive notifications of new posts by email.

Read More

  • Privacy Policy
  • About Anne Gentle, developer experience expert
  • Books by Anne Gentle
    • Conversation and Community
    • Docs Like Code, a Book for Developers and Tech Writers
  • Woman in Tech Speaker Profile
  • Contact

Books

  • JustWriteClick
  • Contact
  • Books by Anne Gentle
  • Introducing Docs Like Code

Copyright © 2025 · WordPress · Log in