TechJunkie is a BOX20 Media Company

Home Web The Ultimate Guide To Proper Date Formatting In File Names

The Ultimate Guide To Proper Date Formatting In File Names

This guide is for anybody that has a whole bunch of files, be they photos, MP3s, documents or any other type of file you have that needs quick-sorting by date at a glance.

There is only one right way to put the date in a file name. When I say “date in a file name” I mean that the actual title of the file has the date in it.

The format you must use for proper date formatting every time is:

  1. Four-digit year
  2. Dash
  3. Two digit month or single digit month with leading zero
  4. Dash
  5. Two digit day of month or single digit day of month with leading zero
  6. Underscore
  7. Description of file in lowercase letters with words separated by underscores (optional, but more compliant)

Here’s an example:

2009-03-27_my_document.doc

Now I’m going to explain why this is the proper date formatting structure for file names.

Four-digit year

You do this so as not to confuse a year with a month. If you have a date written as 08-07-08, is that August 7, 2008 or 8 July, 2008? You can’t tell.

“That doesn’t matter, I always use month/day/year.”

It does matter because not everybody uses month/day/year.

Two digit month or single digit month with leading zero

A two digit month is each enough to understand. For example, December is 12.

A single digit month, like May, is 5. But you don’t write it like that. You add in a leading zero so it’s written as 05.

Why?

Because some operating systems will not list files in proper numeric order without the leading zero. Windows XP and all previous versions prior to it do this.

Example: You have 10 DOC files from 0 to 10. The single digits have no leading zeroes on them.

This will show in XP in Windows Explorer as:

0.doc
1.doc
10.doc
2.doc
3.doc
4.doc
5.doc
6.doc
7.doc
8.doc
9.doc

Note the 1 and the 10 are right on top of each other. Why does XP do this? Because 1 comes after 0, before 2 and all other numbers. XP is only going by the first character it “sees.”

Even Windows Vista and 7 still do this when listing files outside the Windows Explorer interface (such as a File/Open dialog box.)

Second example: 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10

All these numbers will be listed in proper order. 0 always comes before 1, and even with the way Windows lists files, it absolutely will not get this “wrong”; that’s why you do it.

Two digit day of month or single digit day of month with leading zero

You do this for the exact same reason as for the month.

Underscore

The underscore (this character: _) is necessary because the dates uses dashes already. Using underscores gives a clean visual cue as to what’s a descriptor and what’s a date.

In addition, you use underscores because trying to send a file over the internet with a literal space in it results in a %20, or just fails on attempt to transfer. A replacement must be used for the space to avoid this. Underscore is it.

Description of file in lowercase letters with words separated by underscores

As said above, this is optional. You use lowercase just in case you ever have to upload this from a command line via FTP. Where case of letters is involved, mistakes can be made easily – especially if it’s a long file title. If you know all the letters are lowercase, this decreases typing mistakes significantly.

Why Year/Month/Day and not Year/Day/Month?

Year/Month/Day is proper big endian formatting and follows ISO 8601 international standard. Year/Day/Month does not. You can see more info here on that if you like.

Okay, so I know a bunch of stuff about date formatting in files now. Why should I care?

You should care for three good reasons.

First and most obvious, it will make your files easier to manage no matter what OS you use. And if you plan on sticking with XP for a while longer, this is mandatory because of the way it lists files starting with digits.

Second, being that the world is getting smaller every day, chances are you’ll be trading files with someone across the pond sooner or later, if not doing so already. Using the internationally recognized big endian standard eliminates any and all confusion as to what a date format truly represents.

Third, in addition to files being sorted properly no matter the OS you use, they will also sort properly no matter what web site you use. Using Windows SkyDrive, Google Docs, plain FTP or other means of online storage? You’ll be able to sort a whole lot easier using proper date formatting in the titles of your files.

Wouldn’t it be easier just to sort by date modified or date created?

Not necessarily because it can add in many repetitive steps.

In Windows (XP/Vista/7,) two columns that can be added via Windows Explorer are Date Modified and Date Created. However in order to see these, you have to be in Details view mode when looking at files.

Date Modified is usually there by default, but Date Created isn’t, so you have to add that in by right-clicking a column to see all that are available, then choose Date Created so it can be seen.

Example from Windows XP:

image

To get to this point, it took five clicks just to see this stuff.

  1. View
  2. Details
  3. Right-click column
  4. Date Created
  5. Click to sort by date created

You may have to do this over and over again – particularly in XP – because this view mode may not be “remembered” by Windows. It can get very frustrating quickly.

Adding in the date to the title of the file eliminates the need to do any of this.

Where would using date formatting like this in file titles be most useful?

Three instances comes to mind:

  1. Photos
  2. Documents
  3. Dated audio or video broadcasts

Is there ANY WAY to automate the process of renaming multiple files with the date like this?

Absolutely. The tool you need is Rename Master for Windows. Here’s how to use that software to modify as many files as you want – all at once – with their creation date at the front:

1. Launch Rename Master.

2. Remove all existing steps. This is done easily by clicking Edit then Clear Renaming Options, like this:

image 

3. In RM, navigate to the folder where the files are. Do this by using the Folder Browser on the left of the application. If you don’t see it, press CTRL+B while using Rename Master.

4. Click the New Step button, then Add to Beginning/Ending, like this:

image

5. Add the following in: ?dc:FYYYY-MM-DD?_

Yes, I know that looks weird, but it works. It looks like this:

image

Make sure to select “at the Beginning” and “to the Name” as shown above.

6. Click the New Step button again and choose to Replace Name/Phrase, like this:

image

7. Set the step to look like this, and follow the steps carefully:

image 

Next to “Replace the” we select phrase. This will enable the other fields.

In the field directly to the right of phrase, click inside and press the spacebar once to add in a space. You cannot see this in the screen shot above because a space obviously cannot be seen.

In the field directly to the right of with, type in an underscore (this character: _).

8. Click the Case & Wildcards tab, check Override configuration settings and tick the option for lowercase, like this:

image

9. Compare the Name to the New Name column to make sure the appropriate changes will be made.

image

Above is exactly what we want. The best example is “New OpenDocument Text.odt.”

As you can see from the New Name column, it will be changed to:

2009-09-23_new_opendocument_text.odt

The file creation date is added using the proper date formatting. All spaces are replaced with underscores and letters that were capitalized are changed to lowercase.

After that it’s a click of this button:

image

(Located at the bottom of Rename Master)

..and that’s all there is to it.

Always remember to proceed carefully with the renaming of files, especially for large amounts of them. Pay close attention to the New Name column in Rename Master when using the software, because whatever you see there is exactly what the files will be renamed to verbatim. So if it looks wrong, it is wrong. Correct it before hitting that rename button at the bottom.

Final notes for Vista/7 users

As you know, file permissions are needed in order to rename files in specific places. RM may not function correctly if you try to modify files it doesn’t have proper access to. To overcome this, rename files that you have located either in a specific folder you create on the desktop or a specific folder you create in My Documents. RM should work without issue when renaming files from those locations. Just remember to create a specific folder to do it so you don’t rename anything else by mistake.

When Should You Update Your Firmware?

Read Next 

2 thoughts on “The Ultimate Guide To Proper Date Formatting In File Names”

Nathaniel says:
The description is often the primary data point so sometimes this should go first. What I was really hoping was to find a recommendation for the time portion of a date.

Here is what I have so far (C#), but I’m not a fan of the “.” for the time:

private static string CreateMeaningfulFileName(string friendlyName, DateTime date)
{
StringBuilder sb = new StringBuilder();
foreach (string s in friendlyName.Split(new char[] { ‘ ‘ }))//remove spaces
{
sb.Append(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s.ToLower()));//capitalize each segment
}
sb.Append(“_” + date.ToString(“yyyy-MM-dd_HH.mm”));//add date
return sb.ToString();
}

J says:
Good article. I will definitely implement this strategy. I was naming files with the date at the end of the file name “Company_061510″ for June 15 2010. and once a year rolled over the order was incorrect. Can this format be used with other punctuation? Your example states”2009-03-27_my_document.doc” could I use “2009.03.27_my_document.doc” or “20090327_my_document.doc” or “2009-03-27 My Document.doc” with the same effect. Thanks for a great how to.

Leave a Reply

Your email address will not be published.


Nik

Sep 24, 2009

643 Articles Published

More