Thursday 16 May 2024

File Naming Tips (dates)

It is common for users (all of us) to want to put a date in the name of a file or folder to indicate when it refers to and to ensure this is maintained even if the file modification date itself gets changed. 

There is nothing wrong with this however there are some simple basic things you should consider which will make this clearer and work better.

As you may be aware, the ’standard’ UK date format is DDMMYY, the standard US data format is MMDDYY neither of these works well for file names for a simple reason. This is because computers will sort file names ‘alphabetically’ and ’numerically’ and these two formats do not therefore sort the way you expect which is based on ascending or descending dates.

For example - to a human based on in this example UK date formats.

180121 (i.e. 18th, January, 2021)

Is older than -

130224 (i.e. 13th, February, 2024)

However to a computer the ’number’ 130224 is ‘lower’ than 180124 and hence the compute will not sort these based on the dates as you might intend. Even worse you may have a date like 060622.

There is a very, very simple solution. Use the following date format in file names -

YYMMDD

This will aways sort in the intended date order. Using the same two example dates -

210118 (i.e. 18th, January, 2021)

is older and lower than -

240213 (i.e. 13th, February, 2024)


Note: writing dates with separators as 18/01/21 (UK) or 01-18-21 (US) or (if you are Italian) 18.01.21 makes no difference, it will still go wrong. So stick to 210118 i.e. YYMMDD,