How can I rename photo files using the EXIF capture date?

Asked 12/25/2018

4 views

2 answers

0

I have about 3,000 JPEG photos with generic filenames like DSC_0596.jpg, but each file contains EXIF metadata with the capture/creation date. Is there a way to batch rename the files so the filename includes that EXIF date, such as YYYYMMDD-HHMMSS.jpg or similar? Ideally this would work on many files at once and avoid filename collisions.

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

Photography Stack Exchange contributor

7y ago

2 Answers

29

ExifTool is pretty much the Swiss army chainsaw for doing these kinds of things. It has a steep learning curve, but once you're over it, the kind of renaming you're after is a snap:

exiftool -d '%Y%m%d-%H%M%%-03.c.%%e' '-filename<CreateDate' .

The -d switch tells ExifTool to format dates according to the next argument's pattern. The pattern contains date format codes that fill in various bits and pieces from the date. This would rename a file taken today at 17:34 to 20181226-1734-000.nef. The three zeros after the time are a copy number put there by %%-03.c in the date format. I'll explain why that's important in a minute.

The next argument tells ExifTool to change the filename to whatever is in the CreateDate field in the EXIF using the date format specified earlier.

Finally, the . is the path of the directory where you want to operate. You can also specify individual images if you want.

About the copy number: This is an important thing to put in your filenames because many cameras don't provide fractional seconds in their timestamps. If you had multiple files created during the same second, each successive rename would overwrite the last file and all you'd get is the last one. When picking a name, ExifTool will keep incrementing the copy number until it finds a filename that doesn't exist and rename the file to that. Note that this does not weed out duplicates. If you use this method to copy images from a card into some other directory and then run it again on the same set of images, you will end up with identical files numbered 000 and 001.

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

user6508

7y ago

0

AI Answer

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

Yes. A common way to do this is with a metadata tool that can read EXIF and rename files in bulk.

Two tools mentioned were:

  • ExifTool — very powerful and flexible for renaming from EXIF fields like CreateDate or DateTimeOriginal.
  • jhead — simpler for JPEG-only workflows.

Examples from the community:

  • ExifTool: exiftool -d '%Y%m%d-%H%M%%-03.c.%%e' '-filename<CreateDate' .

    This formats the EXIF date into the filename and adds a copy number to avoid duplicates.

  • jhead: jhead -n%Y%m%d-%H%M%S *.jpg

    This renames JPEGs to a timestamp-based filename such as 20181226-111141.jpg.

If multiple photos share the same second, use a numbering/copy suffix so files don’t overwrite each other. If your photos use DateTimeOriginal rather than CreateDate, choose that field instead. Always test on a copy first before batch-renaming a large archive.

UniqueBot

AI

7y ago

Your Answer