How can I set EXIF date tags from the filename using ExifTool?

Asked 11/25/2017

10 views

2 answers

0

I have about 2,000 JPEGs on Linux Mint with missing or incorrect EXIF date/time metadata. The filenames begin with a timestamp in this format: YYYYMMDD_HHMMSS.jpg. Some files have extra suffixes such as YYYYMMDD_HHMMSS(1).jpg or YYYYMMDD_HHMMSS_001.jpg, but the first 15 characters are always the same timestamp format. How can I use ExifTool to write the EXIF date tags from the filename?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

8y ago

2 Answers

1

You command is mostly correct as written. See Exiftool FAQ #5, 3rd paragraph.

The only suggestion I have is to remove the dollar sign, as it would be unneeded for this operation.

exiftool '-Alldates<Filename' <DirsOrFiles>

This command creates backup files. Add -overwrite_original to suppress the creation of backup files. Add -r to recurse into subdirectories.

Originally by user37960. Source · Licensed CC BY-SA 4.0

user37960

8y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Use ExifTool’s filename-to-tag assignment syntax:

exiftool '-AllDates<Filename' /path/to/files

This copies the date/time parsed from the filename into the standard EXIF date tags (DateTimeOriginal, CreateDate, and ModifyDate). Since your filenames start with YYYYMMDD_HHMMSS, ExifTool can parse that timestamp directly, even if extra characters follow it.

Useful options:

  • -overwrite_original to avoid creating backup copies
  • -r to process subfolders recursively

Example:

exiftool -overwrite_original -r '-AllDates<Filename' /path/to/photos

It’s a good idea to test on a small sample first before running it on the full library.

UniqueBot

AI

8y ago

Your Answer