How can I set EXIF date/time from filenames like 2023_01_11_001.jpeg?
Asked 12/6/2025
4 views
2 answers
0
I have several hundred JPEGs with filenames in the format YYYY_MM_DD_NNN.jpeg, for example:
2023_01_11_001.jpeg
2023_01_11_002.jpeg
2023_01_17_001.jpeg
They currently have no useful EXIF date information. I want to set the capture date from the YYYY_MM_DD part of the filename, and derive a time from the numeric suffix so that 001 becomes 00:01, 002 becomes 00:02, etc. The goal is for photo library software to sort them by the date taken. What is a good way to batch-write this metadata?
Originally by Chris. Source · Licensed CC BY-SA 4.0
Chris
6mo ago
2 Answers
3
This is relatively easy to achieve with the excellent ExifTool. The process should be similar for both Windows and MacOS (since the tool is available for both). Given that you have the executable installed and available on the path, you'd browse to the directory where the images in question are (assuming that there aren't other files there), open a terminal there and do the following:
exiftool "-DateTimeOriginal<filename" -d "%Y_%m_%d_%M.%%e" "-FileModifyDate<filename" -d "%Y_%m_%d_%M.%%e" .
The part with "-DateTimeOriginal<filename" -d "%Y_%m_%d_%m.%%e" tells it to read the current filename, parse the time from it and write it into the DateTimeOriginal tag; likewise with FileModifyDate, only that it writes to a different meta field. The . at the end means "the current directory" (so it would process all files in it), alternatively you could point it to another directory (with an absolute path or with a path relative to the current one), or to just a specific file with the -filename switch.
If your filenames differ, you can change the "%Y_%m_%d_%m.%%e" part accordingly. Of course this assumes that all the files there are named in a similar manner; if they're not, you would have to split them and process them separately, or rename them first so that they all follow the same pattern and then process them in one go.
Here are all the placeholders that you can use (copy-pasted from the site):
%a - abbreviated locale weekday name
%A - full locale weekday name
%b - abbreviated locale month name
%B - full locale month name
%c - preferred locale date/time representation
%d - day of month (01-31)
%f - fractional seconds (see note 1 below)
%H - hour on a 24-hour clock (00-23)
%I - hour on a 12-hour clock (01-12)
%j - day of year (001-366)
%m - month number (01-12)
%M - minute (00-59)
%p - 'AM' or 'PM'
%s - number of seconds since the Epoch, UTC (see note 2 below)
%S - seconds (00-59)
%w - weekday number (0-6)
%W - week number of the year (00-53)
%x - preferred locale date representation
%X - preferred locale time representation
%y - 2-digit year (00-99)
%Y - 4-digit year (eg. 2006)
%z - time zone in the form +/-hhmm (see note 2 below)
%Z - system time zone name (see note 3 below)
%% - a literal '%' character
If you have the hour besides the minutes, you can add it too.
By default exiftool creates a backup copy of each image it processes; you can disable that by adding -overwrite_original to the command.
Originally by K. Minkov. Source · Licensed CC BY-SA 4.0
K. Minkov
6mo ago
0
Generated from our catalog & community — verify before relying on it.
A practical way to do this is with ExifTool, which can parse values from the filename and write them into metadata in bulk.
From the folder containing the images, run ExifTool with assignments that copy the filename into DateTimeOriginal and FileModifyDate, using a date format string that matches your naming pattern.
Example approach:
- read the filename
- parse
YYYY_MM_DD - use the numeric suffix as minutes (
001→00:01,002→00:02) - write the result to
DateTimeOriginal - optionally also write
FileModifyDate
The community recommendation is ExifTool because it works well for this kind of batch metadata task on both Windows and macOS. Before running it on your whole library, test on a few copies first to confirm the parsed times are exactly what you want.
One caveat: if you have suffix values above 59, they won’t map cleanly to minutes in a normal HH:MM time, so you may need a slightly different mapping for those files.
Recommended products
UniqueBot
AI6mo ago
Your Answer
Related Questions
How do I use jhead to rename photos by date with a sequential counter?
How can I keep only one timelapse photo per hour from a week of 1-second shots?
Can Lightroom export files with zero-padded sequence numbers?
How can I batch-set EXIF dates from a parent folder name in ExifTool?
How can I set photo 'Date Taken' EXIF metadata from the filename?