TransWikia.com

Change EXIF and/or Creation date based on folder name

Photography Asked by H L M on March 17, 2021

I have lots of photos with non-existent exif dates where the write date is not correct. The original dates disappeared during a hard drive replacement. But they are in folders with the correct date.

Example: folder name "2003-01-22" contains photos with writing date 2017-05-20.

I want to be able to change / add exif and write the date based on the folder name.

Any good ideas?

One Answer

Assuming there are no other numbers in the directory path, you could use
exiftool "-AllDates<$Directory 00:00:00" /path/to/files

That would set the EXIF timestamps to midnight on the date in the filepath.

If there are other numbers in the directory path, then a complex command would have to be used. Assuming the date is exactly as you posted
exiftool "-AllDates<${Directory;m/(d{4}-dd-dd)/;$_=$1}" /path/to/files

These commands cannot be run from that directory, i.e. using a dot to indicate the directory. They must be run from above that directory using the -r (-recurse) option or must include the date as part of the indicated path, e.g. /path/to/2003-01-22/.

This command also does not affect the file system time stamps. To set those as well, duplicate the center part but replace AllDates with FileModifyDate or FileCreateDate.

This command will overwrite any existing timestamps, so make sure you're processing the correct files (see the -wm (-writemode) option for ways to alter this). This command creates backup files. Add -overwrite_original to suppress the creation of backup files. If this command is run under Unix/Mac, reverse any double/single quotes to avoid bash interpretation.

Answered by StarGeek on March 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP