My initial experience with exiftool and a word of thanks

Started by kngharv, June 09, 2021, 09:13:45 PM

Previous topic - Next topic

kngharv

I would like to thank Mr. Harvey for creating this tool.

In some way, this tool is perfect for me.  I am someone who has been taking photographs consistently since my first high school job, which allow me to buy films and pay for developments and prints. As soon as Kodak start to offer PictureCD,  I jump on it immediately just because the quality of scan from negative is far more superior.

I jump onto dSLR rather late.  But most dSLR doesn't have geotag function until very recently, and most model sold on the market today doesn't have any geotag feature built in, which I personally think it's a crime.

Around 2016 time frame, I finally managed to find dSLR accessories that either receive GPS signal directly or tether GPS signal from my mobile phone.   My photos finally have a relatively "complete" exif data for the first time.   Having said that, because the GPS signal rely on this accessory to set up properly before I shoot, not all photos contains GPS data.

The direct result of my long photography experience is that I have photographs that
1. Has no exif data whatsoever
2. has exif data that contains the date
3. has date and geotag info.

My goal is to
1. Separate photographs into three different bins: those with no exif data, those with exif date but not geotag,  and those with geotag
2. go through old photographs and reconstruct date/geotag metadata manually and write the data to the picture file
3. eventually, write people's name in the photograph in some exif field

Because of the sheer amount of photographs I have, I knew from the start that I need a commandline tool.   I settled with exiftool after a couple hours of trying different tools.  Honestly, having a vibrant forum help big time.

Having said that, my initial experience was extremely frustrating. 

Remember,  My initial goal is simply separate photographs into different bucket depend upon rather the exif contains geotag, date or nothing at all.   I spend close to 5 hours trying to format date with no avail,  simply because I was using "gpsdatestamp" as my selection criteria and I didn't know the -d formatting doesn't apply to gps time nor gps date.

Yes, I know, RTFM,  but let's be honest,  exiftool is a rather complex tool and manual is quite long, ok?   It is not reasonable to assume people going to read the whole man page before he starts to play with it.

In any case,  I have gotten quite far with this tool. And I am pleasantly surprised by the performance of this tool.

With this tool, I finally get to organize my photographs in a real way.  I insist on trying to get the metadata right simply because I know i won't able to find anything if photographs' metadata isn't correct.   Everything else, photo galleries searches, etc, will be hopelessly depend upon metadata to function properly.

I thank you for making this tool available.

I do want to give you guys a heads up, though.  I will probably have more question later, and a lot of the question will be more to do with EXIF than the tool itself.  I figure this is the best place to ask exif related question than anywhere else.

Again, thank you.  You've made my memory searchable and recall-able.

Harv  8)

Luuk2005

Greetings Harv! This example guesses that 'exif date' means to prefer $DateTimeOriginal, but also to grant $CreateDate.
Its using the below subdirectory logic, so please to modify the description if the guessing is still incorrect.

CurrentParentFolder/noEXIF/file.ext                               if file has NO exif whatsoever
CurrentParentFolder/timeStamp/YYYY-MM-DD/file.ext     if file has $DateTimeOriginal or $CreateDate (but not $GPSDateStamp)
CurrentParentFolder/geotag/YYYY-MM-DD/file.ext           if file has $GPSDateStamp (preferred better than above)

exiftool -d %Y-%m-%d -directory'<${Directory}/timeStamp/$CreateDate' -directory'<${Directory}/timeStamp/$DateTimeOriginal' -directory'<${Directory}/geoTag/${GPSDateStamp;tr/:/-/}' -execute -if 'not $exif' -directory'<${Directory}/noexif' -common_args DIR    
So this could move any files having those $Tags, but if any files have exif-data without those $DateTags, they would not get moved.
Im not understand why -d wont modify $GPSDateStamp, so hoping the experts will advise, but guessing its not really classified a $DateTag ????
You can blame me for all the troubles, because earlier Im giving a bad example without removing the -m option first!!

Also, Im just guessing with the single-quotes everywhere for your shell, so maybe needing to change some of them.
Im not expert to help with the metadata questions, but usually I can help if there is some regex troubles.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Luuk2005

I did forget to put the options on different lines, so maybe this can look better for the eyesight...

exiftool -d %Y-%m-%d -directory'<${Directory}/timeStamp/$CreateDate'
                                     -directory'<${Directory}/timeStamp/$DateTimeOriginal'
                                     -directory'<${Directory}/geoTag/${GPSDateStamp;tr/:/-/}' -execute
                 -if 'not $exif' -directory'<${Directory}/noexif' -common_args DIR

Everything before -execute is looking for $Tags to create the sub-directory, with the last $Tag (GPSDateStamp) always being most preferred.
After -execute, its looking for files without any $Exif to create the 'noexif' sub-directory (so its like another execute, without having to restart).

The -common_args is for options like DIR that should always be used (can use many -execute's, but not at the very end).
So like if always wanting to recurse, could use -common_args -r DIR at the very end.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

StarGeek

The NoExif part can be folded into the first part of the command.  Just place it before all the others because subsequent assignments take priority.  So if you put it first, any file that has a CreateDate, DateTimeOriginal, or GPSDateStamp tag will override that assignment.

I used GPSLatitude instead of one of the GPS time tags because it could be possible (if unlikely) to have a GPS timestamp but not a coordinate.  This is something I do when I have a vague location e.g. somewhere in Los Angeles or New York City, but not the exact GPS coordinates.  This way you know there definitely is at least one coordinate.

I'm using the -d (-dateFormat) option format as a just a static string, though I could also use the same trick I used with the GPSLatitude.  This condenses the command a little bit.

I'm taking @kngharv at their word that they only want three directories.  If subdirectories by date are desired, then combining @Luuk2005's date format with mine will achieve that result e.g. -d "With_EXIF_time/%Y-%m-%d"

Finally, I'm using Filename instead of Directory in case there are any filename collisions.  Swap double quotes for single quotes if on Mac/Linux/Powershell.

exiftool -d "With_EXIF_time" "-FileName=%dnoexif/%f%-c.%e" "-FileName<%d$CreateDate/%f%-c.%e" "-FileName<%d$DateTimeOriginal/%f%-c.%e" "-FileName<%d${GpsLatitude;$_='With_GPS'}/%f%-c.%e" /path/to/files/

There will be minor errors thrown for files that may be missing tags (see example output below), but this may be suppresed with the -m (-ignoreMinorErrors) option.

Example output using TestName instead of Filename
C:\>exiftool -d "With_EXIF_time" "-Testname=%dnoexif/%f%-c.%e" "-Testname<%d$CreateDate/%f%-c.%e" "-Testname<%d$DateTimeOriginal/%f%-c.%e" "-Testname<%d${GpsLatitude;$_='With_GPS'}/%f%-c.%e" Y:\!temp\bb
Warning: [minor] Tag 'CreateDate' not defined - Y:/!temp/bb/NoExif.jpg
Warning: No writable tags set from Y:/!temp/bb/NoExif.jpg
'Y:/!temp/bb/NoExif.jpg' --> 'Y:/!temp/bb/noexif/NoExif.jpg'
Warning: [minor] Tag 'GpsLatitude' not defined - Y:/!temp/bb/WithExifTimestamp.jpg
'Y:/!temp/bb/WithExifTimestamp.jpg' --> 'Y:/!temp/bb/With_EXIF_time/WithExifTimestamp.jpg'
Warning: [minor] Tag 'CreateDate' not defined - Y:/!temp/bb/WithGPS.jpg
'Y:/!temp/bb/WithGPS.jpg' --> 'Y:/!temp/bb/With_GPS/WithGPS.jpg'
    1 directories scanned
    0 image files updated
    3 image files unchanged
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

Quote from: kngharv on June 09, 2021, 09:13:45 PM
3. eventually, write people's name in the photograph in some exif field

There's no EXIF tag that is normally used for names, but there are multiple XMP tags that can be used.  There are four of the complex structures used to mark regions, which are the ACDSee regions, IPTC regions, Microsoft Photo Gallery regions, and MWG regions.  The last is the most widely supported, including support by Lightroom.  All four have a region name type tag which can be used for holding the names of people, though support from programs might be questionable without actually having regions defined.

More common for just names would be the XMP:PersonInImage tag.  This is a list type tag (see FAQ #17).

Then there is always the keyword tags, IPTC:Keywords, XMP:Subject, and XMP:HierarchicalSubject.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).