ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: jimcampbell100 on September 19, 2010, 02:21:48 PM

Title: Set exif data based on directory name
Post by: jimcampbell100 on September 19, 2010, 02:21:48 PM
I've received a load of scanned files that are all sorted into directories containing the year and month taken.  For example:

c:\photos\2009 12 - Christmas\photo1.jpg

The create date and date taken fields are both set based on the date they were scanned (obviously).  I'd like some way to set these fields based on the data in the path.  The day can just be the first day of the month.

Possible?  I hope so - I have a couple thousand files!

Thanks for any help--

Jim
Title: Re: Set exif data based on directory name
Post by: Phil Harvey on September 19, 2010, 04:02:22 PM
Hi Jim,

This is similar to what was done in this thread (https://exiftool.org/forum/index.php/topic,2741.0.html).

If there are no other numbers in the directory name, you can do this without a user-defined tag like this:

exiftool -r "-createdate<$directory 01 00:00:00" ROOTDIR

The "01 00:00:00" fills in the necessary day, hr, min and sec values.  Note that single quotes should be used instead of double quotes if you are on Mac or Linux.

If there may be other numbers in the directory name, you can create a user-defined tag to extract the necessary parts from the directory name (as in other thread), but this requires a bit of Perl knowledge.

- Phil
Title: Re: Set exif data based on directory name
Post by: jimcampbell100 on September 19, 2010, 04:19:33 PM
Worked like a charm!  Thanks!