How to Rename Files with Custom Date Formats on Mac

Date format strings control exactly how dates appear in your filenames. Understanding format tokens lets you create any date pattern from compact YYYYMMDD to verbose "March 26, 2026" formats. This guide covers every common token and explains which patterns work best for different use cases.

What Are the Core Date Format Tokens?

The core date format tokens are yyyy for four digit year,MM for two digit month, dd for two digit day,HH for 24 hour hours, mm for minutes, andss for seconds. These tokens follow the DateFormatter standard used by macOS and Batchio.

Each token represents a specific component of a date or time value. The case sensitivity of tokens matters: uppercase MM means months while lowercasemm means minutes. Similarly, uppercase HH uses 24 hour time (00 through 23) while lowercase hh uses 12 hour time (01 through 12). The token yy produces a two digit year (26) while yyyy produces the full four digit year (2026).

Additional tokens include SSS for milliseconds, EEEE for the full day name, EEE for the abbreviated day name, MMMM for the full month name, and MMM for the abbreviated month name. Any characters in the format string that are not recognized as tokens are inserted literally. This means you can use hyphens, underscores, dots, and spaces as separators between date components.

What Are the Most Useful Date Format Patterns?

The most useful patterns are yyyy-MM-dd (ISO 8601 date),yyyyMMdd (compact date), yyyy-MM-dd_HHmmss (date with time), and yyyyMMdd_HHmmss (compact date with time). ISO 8601 is recommended for general use because it sorts correctly and is universally understood.

The ISO 8601 pattern yyyy-MM-dd produces filenames like 2026-03-26_report.pdf. This format is the international standard for date representation and sorts correctly in every file browser. The compact variant yyyyMMdd saves four characters per filename by omitting the hyphens, producing 20260326_report.pdf. Both patterns maintain correct alphabetical sorting because the year appears first.

Adding time components creates more specific timestamps for workflows where multiple files share the same date. The pattern yyyy-MM-dd_HHmmss produces 2026-03-26_143022_photo.jpg, indicating the file was created at 2:30:22 PM. For photo collections with burst shots, the millisecond token SSS adds sub second precision. See the date insertion guide for guidance on choosing prefix versus suffix positioning.

How Do ISO 8601 and Localized Formats Compare?

ISO 8601 (yyyy-MM-dd) sorts correctly in alphabetical order and works across all operating systems. Localized formats like DD.MM.YYYY (European) and MM/DD/YYYY (US) are familiar to their respective audiences but break alphabetical sorting and may use characters that conflict with file path separators.

ISO 8601 prioritizes machine readability and universal compatibility. The year first ordering ensures that chronological sort matches alphabetical sort in every file browser on every operating system. This format is also unambiguous: 2026-03-26 can only mean March 26, 2026. There is no confusion between month and day because the format is standardized globally.

Localized formats prioritize human readability for a specific region. The European format dd.MM.yyyy produces 26.03.2026, which reads naturally for European users but sorts incorrectly in file browsers. The US format MM/dd/yyyy uses forward slashes that conflict with macOS path separators, making it unsuitable for filenames. When you need localized dates, use dots or underscores as separators instead of slashes. For renaming by creation date specifically, see the creation date guide.

How Do You Use Custom Date Formats in Terminal?

Terminal formats dates using the date command with + followed by format specifiers. The command date +%Y-%m-%d outputs the current date in ISO 8601 format. Terminal uses different tokens than DateFormatter: %Y for year, %m for month, %d for day, %H for hours.

Terminal's date formatting uses POSIX strftime tokens, which differ from DateFormatter tokens. The %Y token produces a four digit year,%m produces a two digit month, %d produces a two digit day,%H produces 24 hour hours, %M produces minutes, and%S produces seconds. Combine these with the stat command to format file creation dates in custom patterns.

The command stat -f %SB -t "%Y%m%d_%H%M%S" photo.jpg outputs the creation date of photo.jpg in compact date time format. Use this output in a for loop to rename files with their creation dates in any format you need. Terminal provides maximum flexibility but requires memorizing a different set of format tokens. Batchio uses the more intuitive DateFormatter syntax. See the date insertion guide for the complete workflow.

How Does Batchio Handle Custom Date Formats?

Batchio's Date Insertion rule accepts any DateFormatter format string. Type the pattern in the format field (for example, yyyy-MM-dd or yyyyMMdd_HHmmss) and the live preview shows the formatted date for every file. Batchio validates the format string and highlights errors in real time.

Batchio supports every DateFormatter token including year, month, day, hour, minute, second, millisecond, day name, and month name tokens. The format field accepts free form input, so you can create any pattern by combining tokens with literal separator characters. The live preview updates as you type, showing you the exact output for every loaded file before you commit the rename.

Common format presets are available for quick selection: ISO 8601 date, compact date, date with time, and full timestamp. You can also save custom formats as part of a preset (Pro feature) for reuse across sessions. Stack the Date Insertion rule with other rules to build complex naming patterns. For example, combine a custom date format with a Change Case rule to standardize both the date and the filename casing in one operation. See the batch rename guide for rule stacking examples.

Frequently Asked Questions

What does yyyy-MM-dd mean in a date format string?
The token yyyy represents the four digit year, MM represents the two digit month (01 through 12), and dd represents the two digit day (01 through 31). The hyphens are literal separator characters. The result looks like 2026-03-26. Uppercase MM distinguishes months from lowercase mm which represents minutes.
What is the difference between MM and mm in date formats?
Uppercase MM represents the month (01 through 12). Lowercase mm represents minutes (00 through 59). Confusing the two produces incorrect filenames. A format string of yyyy-mm-dd inserts minutes instead of months, resulting in filenames like 2026-45-26 instead of 2026-03-26.
Can you include the day of the week in a date format?
The EEEE token inserts the full day name (Monday, Tuesday) and EEE inserts the abbreviated version (Mon, Tue). A format string of EEEE_yyyy-MM-dd produces Wednesday_2026-03-26. Day names add context but increase filename length and can cause sorting issues.
What date format is best for cross platform compatibility?
The ISO 8601 format yyyy-MM-dd provides the best cross platform compatibility. This format is recognized by macOS, Windows, and Linux. It sorts correctly in alphabetical order on every operating system. Avoid using slashes in date formats because they conflict with file path separators on macOS and Linux.

Custom Date Formats Made Simple

Download Batchio free on the Mac App Store. All 9 rule types included. Pro upgrade $4.99.

Coming Soon to the Mac App Store
Marcel Iseli
Marcel Iseli

Creator of Batchio · Indie App Developer

LinkedIn ↗

Marcel Iseli is an indie app developer and the creator of Batchio. He builds native macOS utilities focused on productivity and file management, with a focus on lightweight, subscription-free tools.