Skip to content
Utilboxes

How to name files so they sort in the right order

Dates as YYYY-MM-DD, numbers with leading zeros and no final_FINAL_v2. A file naming scheme that sorts correctly on every computer and makes files easy to find.

Updated

Tools for this job: Sort Lines · Case Converter

To make files sort in order, start each name with a date written YYYY-MM-DD or with a number padded with leading zeros (01, 02 … 10), then a short description, and use hyphens or underscores instead of spaces. Many programs sort names character by character, so “10” lands before “2” unless it is written “02”; leading zeros make the order the same everywhere.

Naming patterns to copy

ForPatternExample
Dated documentsYYYY-MM-DD_description2026-03-14_invoice-acme.pdf
Monthly reportsYYYY-MM_description2026-01_sales-report.xlsx
A numbered sequence (up to 99)NN_description01_intro.docx … 10_appendix.docx
Longer sequencesNNN_description001_scan.jpg … 120_scan.jpg
Versions of one filedescription_vNNproposal_v01.docx, proposal_v02.docx
Photos from an eventYYYY-MM-DD_event_NNN2026-07-04_beach_001.jpg

A folder where “report 10” sorts before “report 2”, where March comes before January, and where three files are called “final” costs a few seconds every time you open it. A handful of naming habits fixes this for good, and they work on Windows, macOS, phones and cloud storage alike.

Rule 1: dates as year-month-day

Write dates as 2026-10-03, the ISO 8601 format. Because the biggest unit comes first, an alphabetical sort is also a date sort. 03-10-2026 and 10-03-2026 sort by day or month first, scattering a year's files, and they mean different dates in different countries.

Rule 2: pad numbers with zeros

Computers often sort names character by character, so “10” comes before “2” because 1 is less than 2. Pad numbers to the same width: 01, 02 … 10, or 001 for hundreds. Some file managers use natural sorting and cope without padding, but many tools, uploads and archives do not.

Rule 3: most important part first

Decide what you will search and sort by, and put it at the front:

  • By date: 2026-10-03-board-minutes.pdf
  • By client: acme-2026-10-03-proposal.pdf
  • By sequence: 03-chapter-three.docx

Rule 4: safe characters only

  • Use letters, numbers, hyphens and underscores.
  • Avoid spaces in files you will share online or use in scripts; web addresses turn them into %20.
  • Never use / \ : * ? " < > |, which Windows does not allow in file names.
  • Pick one case and stick to it. All lowercase with hyphens, known as kebab-case, is the easiest to read and type. The Case Converter turns a title into kebab-case.

Rule 5: versions with numbers, not words

“final”, “final2” and “FINAL-really” tell nobody which is newest. Use v01, v02, v03, and keep the date if versions span days. When a document is truly finished, keep the version number and record it as approved elsewhere, or move it to an “issued” folder.

Check a list of names

To see how a set of names will sort, paste them one per line into Sort Lines. Sort A–Z to see the plain alphabetical order that many systems use, then turn on natural order for numbers to see the order a person would expect. If the two differ, add zero padding. The guide to sorting a list naturally explains the difference.

Renaming files you already have

You do not have to rename a folder of hundreds by hand. In Windows File Explorer, select several files and press F2; type one name and Windows numbers the rest in brackets. In the macOS Finder, select files, right-click and choose Rename, which can add a sequence number or replace text in every name at once. For anything more complex, a dedicated bulk-rename utility is worth installing.

A team convention

Write the scheme down in one short paragraph and share it, with two or three examples. A convention that everyone follows is worth more than a perfect one that nobody remembers. A good default: YYYY-MM-DD-topic-v01.ext.

Tools used in this guide

More tools for this job

All guides