ExifTool Forum

General => Metadata => Topic started by: mikelee33 on March 16, 2017, 10:41:12 AM

Title: -tagsfromfile based on matching datetimeoriginal (and not filename)
Post by: mikelee33 on March 16, 2017, 10:41:12 AM
Good day -

I have created a number of JPG files from CR2 files where the JPG file name is not the same as the original CR2.  For example:  IMG_4018.CR2 and IMG_4018_2.JPG  (and maybe even an IMG_4018_3.JPG if I've created multiple versions)

I would like to use the -tagsfromfile command to copy all the metadata from the original CR2 files to the appropriate JPG files based on their matching datetimeoriginal tags.  While I initially thought about renaming all the files to datetimeoriginal and then simply copying the metadata, this approach I feel is not feasible, and not compatible with my existing filing system.  Could I maybe use an -if expression to conditionally copy when the datetimeoriginal tags match?  If so, how would that be structured?

I might think this a not too uncommon scenario when JPG versioning comes into play.  Any suggestions on how I should proceed?

Many thanks.
Title: Re: -tagsfromfile based on matching datetimeoriginal (and not filename)
Post by: Phil Harvey on March 16, 2017, 10:48:31 AM
Things are much easier if the first 8 characters of the JPG file name give the CR2 file name.  Is this the case?

Otherwise, perhaps you could use the ExifTool HardLink feature to create a set of linked files with common names based on DateTimeOriginal, then use these links to copy the information.

- Phil
Title: Re: -tagsfromfile based on matching datetimeoriginal (and not filename)
Post by: mikelee33 on March 16, 2017, 01:00:31 PM
Hello Phil -

Sometimes the JPG file name (somewhat) mirrors the CR2, sometimes not, and certainly without consistency as to the number of matching characters.

Am I to interpret your reference to the HardLink feature to mean that you might also be inclined to rename the files (temporarily) to DateTimeOriginal?  I can now see how this approach could work, and I will research HardLink further, as I have never used it.

This does give me direction, so thank you.

Mike
Title: Re: -tagsfromfile based on matching datetimeoriginal (and not filename)
Post by: StarGeek on March 16, 2017, 01:30:34 PM
Quote from: mikelee33 on March 16, 2017, 01:00:31 PM
Am I to interpret your reference to the HardLink feature to mean that you might also be inclined to rename the files (temporarily) to DateTimeOriginal?  I can now see how this approach could work, and I will research HardLink further, as I have never used it.

See this thread (https://exiftool.org/forum/index.php/topic,8155.msg41744.html#msg41744) for the basic idea. 
Title: Re: -tagsfromfile based on matching datetimeoriginal (and not filename)
Post by: mikelee33 on March 16, 2017, 04:28:40 PM
StarGeek -

Thank you.  Indeed, that was among the threads I had read when I was initially trying to figure out a way to accomplish my task, and was the very first time I had ever heard of the HardLink feature.  While I don't fully understand it, I will certainly pursue this route.  You have made me aware that the referenced thread is a key discussion on this feature.

Mike 
Title: Re: -tagsfromfile based on matching datetimeoriginal (and not filename)
Post by: Phil Harvey on March 16, 2017, 05:36:53 PM
I think the commands could look something like this:

1. exiftool "-hardlink<tmp/$datetimeoriginal" -d %Y%m%d%H%M%S -r DIR

2. exiftool -tagsfromfile %d%f.CR2 -ext jpg tmp

3. then you should be able to delete the entire tmp folder after making sure that everything went OK.

- Phil