Tech Support Section Home Mekong Network Home
About This Site...
Mekong.Net Sites...
Recently Updated...
Recommended Links...
Contact Us...
Questions? Comments? Requests? Click here to contact us.

DateDir: A Date-Naming Utility for Windows

Click here to download this program.

Click here to download a VBS version of Datedir, compatible with 64-bit Windows. See details below.

Amazing in-action screen cap of folder dating utility Here's the problem: each day, you're backing up a bunch of data with a batch file. But you don't want to overwrite the previous day's backup every day. Wouldn't it be nice if you could put each day's backup in its own folder, and automatically name the folder for the date?

These programs -- datedir.exe, and datedir.vbs -- were designed to make that a little easier. Which version should you use? The .exe is more widely compatible with older operating systems, but will not run on 64-bit systems. The .vbs version has some additional formatting options, but has not been tested with operating systems prior to Windows XP. For the most part, however, the two versions are interchangeable.

Datedir is a command-line program, intended mainly for use in batch files. Give it the name of an existing folder, and it will rename that folder with an integer representing the current date. Alternatively, with no parameters, the command "datedir" will create a new folder named for the current date. The form of the new name is yyyymmdd, where yyyy is the year, mm is the month, and dd is the day. For example, let's suppose the date is November 5, 2002. We type this command:

datedir d:\backups\web_backup_folder

This would rename the "web_backup_folder" as d:\backups\20021105.

A perfectly reasonable question is, why use yyyymmdd? Why not the more common American method of mmddyyyy? Or why not just spell it out, and rename the folder "Nov. 5 2002" or something similar? In general, I think that having spaces inside filenames is a pain in the ass when you are using batch processing and command-line utilities. And, I prefer the year/month/day format because the resulting folders will still sort in correct order even if your windows are set to arrange files by name and not by date.

The ability to rename an existing folder will likely be of more use than the ability to create a new folder named for the date. Suppose, for example, that you want to back up all of the files in your "data" and "document" folders every day, and you wanted to store these in a directory called "backup." A batch file to accomplish would be similar to the following:

REM My daily backup batch file.
mkdir d:\backup\temphold
copy c:\data\*.* d:\backup\temphold
copy c:\document\*.* d:\backup\temphold
datedir d:\backup\temphold

Running this batch file on a daily basis would result in a new directory, named for the date, being created in the backup directory each day that the file was executed.

Note that while wildcards can be used, the program will fail after the first file if there is more than one match for the wildcard pattern. For example, if you have two folders, TEST1 and TEST2, the command "datedir test*" would result in one file being renamed with the current date, but the second file would return an error stating that there was a "duplicate file name or file in use."

I'm aware of a couple minor flaws in the current version:

If an environment variable named "OS" has been created in either a DOS or a Win95 environment, the program will fail, generating an error stating that the OS cannot be identified.

Also, Datedir does not verify that the "directory" you have specified to rename is really a directory. If you pass it the name of a file instead of the name of a directory, it will rename the file.

Datedir is NOT compatible with 64-bit versions of Windows. Although Datedir can handle long filenames, it is actually a 16-bit application. The 64-bit versions of Windows cannot run 16-bit programs. (A VBS script which performs the same function as datedir.exe can be downloaded below.)

One user reported problems when attempting to rename a folder on Windows XP; however, I suspect that this was because the user was running the program under an account with insufficient permissions. I suggested this possibility to the user, and never heard from him (her?) again. That might mean that changing permissions solved the problem, or it might mean that it didn't, and the person just decided that my program was crappy and I'm an idiot, and there was no point in talking with me ever, ever again. I have occasionally seen the program fail when another process was using the directory which was being renamed, but hey, that's not my fault.

One other bug which (hopefully) has now been vanquished: an earlier release of the program (Build 13) had a bug which would cause the rename function to fail under MS-DOS.

Now... having said all that... I'll concede that you can actually set variables and insert the variables into the batch file and rename the files or folders according to the date without this utility... but personally I can never remember how the hell to do that without looking it up every damn time. I can, however, remember how to type "datedir."

Datedir is freeware. It will run on DOS 6.x, Windows 95 and 98, Windows NT, Windows 2000, and Windows XP, and Windows Server 2003. (It should also work with Windows ME, but I never tested it there. I hated ME.) It should be fully capable of handling long filenames, but will still run on DOS. (Personally, I think that's kind of a neat trick.) It was written in Borland C. I've been using it for a couple years, and it has always worked well for me, but be warned: I don't have the resources to thoroughly test on lots of different platforms. Use it cautiously: test it on some junk first before you start using it in mission-critical batch files. You can download Datedir from the software archive here:

A very simple command-line program to create or rename a folder with a number representing the current date. Designed for use in batch files. The .zip file includes the .exe and the program documentation. Written by Bruce Sharp. He's not very bright, so don't expect much. This is Build 24.




What if you're using a 64-bit operating system? And what if you'd like a little more flexibility in the way the file is named? And what if you'd like to see the source code for the thing you're about to install? Since I recently found myself in a position where I needed Datedir on 64-bit Server 2003, I threw together a kludgy little VBScript that works more-or-less the same as the old .exe, with a couple minor enhancements.

One word of caution: at this point, this script has not been tested extensively. The code isn't elegant, but it seems to work on Windows XP, Vista, Windows 7 (32- and 64-bit) Windows Server 2003, Windows Server 2003 x64 Enterprise, Server 2008, and Server 2008 R2.

So what are the enhancements? Datedir.vbs allows you to append the date to the folder name, instead of renaming it completely. You can also customize the format of the name by through the use of command-line parameters:

/a     Append the date (foldername_yyyymmdd)
/r     Reverse format (mmddyyyy)
/t     Time inclusion format (
/u     Underscore format (yyyy_mm_dd)
/v     Verbose format (

For example, suppose you ran the following command at 5:25 PM on January 10, 2009:

datedir.vbs /t c:\mylogfolder

The folder "c:\mylogfolder" would be renamed "20090110_17.25.00".

The optional formats can also be used when creating new folders. The commands "datedir.vbs /r," "datedir.vbs /u," and "datedir.vbs /v," would result in new folders with the following names: "01102009," "20090110_17.25.00," and "Sat_Jan_10_2009_17.25.00."

If you don't have both the .exe and .vbs versions of datedir in your path, it shouldn't be necessary to explicitly say "datedir.vbs." You should be able to simply specify "datedir." In theory (haha), if you had a batch file written for the .exe version which invoked "datedir" instead of "datedir.exe," this would allow you to use the VBS version without modifying the batch file at all.

VBScript gurus who look at the code will realize that I'm doing some goofy things: in particular, the script spawns a new shell in order to execute the rename command when the target directory is not on the local machine. If any real programmers want to suggest better methods, feel free to contact me: help is always welcome. On the plus side, as crude as it is, the script seems to work correctly on local files, mapped network drives, or UNC paths.

The VBS version of Datedir has one significant shortcoming compared to the old .exe: an error can halt execution of the script. Suppose, for example, you try to rename a folder which doesn't exist. Datedir.vbs will pop open an error message... and the script will halt until you've clicked "OK." That can present a problem when datedir is being used in a batch file: none of the subsequent commands in the batch file will execute as long as Datedir is waiting for someone to click that annoying little error message. Depending on what your batch file does, that could present unforeseen problems.

Incidentally, if you've arrived at this page because you're searching for information on how to time-stamp or date-stamp files or folders, feel free to download the VBS version, but be warned: I'm a lousy programmer, and you shouldn't assume that I'm doing things the right way. If you'd like some examples of proper VBScript code, you should take a look at the Scripting Guy Archive on Microsoft Technet. I'd recommend downloading Volume 2 of the Hey, Scripting Guy Archive. It contains more than 800 "Hey, Scripting Guy" columns, compiled into a searchable help file. (Don't ask me why it's "Volume 2." I don't see a "Volume 1" anywhere on the MS site.) Another excellent resource for learning VBScript basics is the W3Schools VBScript Tutorial.

If you're looking for a way to create date-named folders without installing something else on your system, there's a a cool tip for Windows XP in a article by Greg Shultz on TechRepublic. It shows you how to change the default short date format, and then shows you how to add a custom command to your context menu to allow you to create a date-named folder in Windows Explorer. And finally, if you're looking for a more versatile, flexible file renaming tool, I heartily recommend Bulk File Renamer from Bexonsoft.

If, however, you've got your heart set on Datedir.vbs, the current version of the script can be downloaded from the link below:

A crude script to create or rename a folder with a number representing the current date. Designed for use in batch files. Compatible with 64-bit Windows. The .zip file includes the .vbs file and the program documentation. Written by annoying doofus Bruce Sharp. This is Build 28.

Oh, and down here at the bottom of the page, let's add a few keywords to help out anyone using a different spelling of a couple key terms. After all, some people say "time stamp," some say "timestamp," and some say "time-stamp." Same story with "datestamp." Sometimes it's "date stamp," sometimes it's "datestamp," and sometime's it's "date-stamp." And we can't seem to agree on how we should write VBScript, either: sometimes that's VB Script, sometimes V.B. Script, and sometimes Visual Basic Script.