Author Topic: Adding lens info to all files in a folder which don't have it  (Read 70 times)

Quentin

  • Newbie
  • *
  • Posts: 5
Adding lens info to all files in a folder which don't have it
« on: August 18, 2019, 10:53:02 PM »
Hi everyone,

Sorry for what seems like it must be a really common question, but I just can't find an answer to this.  Basically, I want to scan the folder with the photos I've taken today, and if any don't have information about the lens, add the model.

I found: http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=2742.0 but that is for a Mac and when I try that on a PC, it simply tells me all files failed the check.

My camera is the Sony A6000 if that helps.

The command I worked out from that post was:

exiftool -if 'not $lens and not $lensid' -lens="35mm PC lens" ~/Pictures

(I substituted the ~/Pictures for simply . to run in the current folder for now.)

Thanks heaps for taking the time to read this!

Quentin.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: Adding lens info to all files in a folder which don't have it
« Reply #1 on: August 18, 2019, 10:58:52 PM »
exiftool -if 'not $lens and not $lensid' -lens="35mm PC lens" ~/Pictures

Windows uses double quotes around the parts of the command with spaces in it, so change
'not $lens and not $lensid'
to
"not $lens and not $lensid"
and it should work.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Quentin

  • Newbie
  • *
  • Posts: 5
Re: Adding lens info to all files in a folder which don't have it
« Reply #2 on: August 18, 2019, 11:38:46 PM »
Ah, getting somewhere.  I should have said, I worked out the other day to change the single quotes ' for double quotes "

What I hadn't realised, was the camera IS assigning LensID and that is why the condition is failing.

So, how can I tell it:

exiftool -if "$LensID = Unknown E-mount lens" -LensID="Meike 35mm F1.7 Manual" .

Currently, I'm getting: "Warning: Expected one or more integer values in XMP-aux:LensID (ValueConvInv)
Nothing to do.", so I know that's not right :)

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: Adding lens info to all files in a folder which don't have it
« Reply #3 on: August 18, 2019, 11:53:28 PM »
A single equal sign = is used to assign a value.  Double equal signs == is a numeric comparison.  If you wish to do an exact string comparison, then you would use eq e.g. -if "$LensID eq 'Unknown E-mount lens' ".  You have to put the inner string in single quotes to keep it together.  This has to be an exact match.  An extra space or a different case letter will cause it to fail.

If you want to do a partial string match, then you would use a regular expression (RegEx), something like  -if "$LensID=~/Unknown/i"  The trailing i indicates a case insensitive comparison.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Quentin

  • Newbie
  • *
  • Posts: 5
Re: Adding lens info to all files in a folder which don't have it
« Reply #4 on: August 19, 2019, 12:09:54 AM »
Thanks so much for your patience!

I'm still getting the "Warning: Expected one or more integer values in XMP-aux:LensID (ValueConvInv)
Nothing to do." when I use either:

exiftool -if "$LensID eq 'Unknown E-mount lens'" -LensID="Meike 35mm F1.7 Manual" .
or
exiftool -if "$LensID=~/Unknown/i" -LensID="Meike 35mm F1.7 Manual" .

I put this in a batch file, but I just tried it directly on the command line, just in case, and still getting that error.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: Adding lens info to all files in a folder which don't have it
« Reply #5 on: August 19, 2019, 01:10:59 AM »
Ah, my apologies for not paying close enough attention.

It looks like exiftool expects LensID to be numbers, not a string value.  Usually there would be a table on the Tag Name page but not in this case.  It also appears to be a Adobe specific tag.  There might be an Adobe table someplace to translate what numbers are supposed to be there and what they would mean, but I can't find one off hand.

Basically, **Jedi hand wave** this is not the tag you're looking for.

You probably want either EXIF:LensMake, EXIF:LensModel, XMP-exifEX:LensMake, and/or XMP-exifEX:LensModel.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Quentin

  • Newbie
  • *
  • Posts: 5
Re: Adding lens info to all files in a folder which don't have it
« Reply #6 on: August 19, 2019, 01:27:56 AM »
Ok, I think I've finally got it!

LensModel was set to ----
SO:

exiftool -if "$LensModel=~/----/i" -LensModel="Meike 35mm F1.7 Manual" .

Seems to work!

What was throwing me was if I get Exiftool to show me the data, it tells me LensID is set to "Unknown E-mount lens".  What I expect it must be READING is that LensID is set to some number that MEANS "Unknown E-mount lens", and was helpfully interpreting that for me?

Anyway, I'm happy with being able to set LensModel.  Particularly as there's a parcel arrived today with another manual lesn - at least I know all the files to now are from the Meike.  Now I can make a batch file for each and just run the appropriate one as needed.  Thank you!

That was a lot more complicated than I expected it to be for what I thought would be a simple command.

Quentin.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: Adding lens info to all files in a folder which don't have it
« Reply #7 on: August 19, 2019, 02:09:32 AM »
What was throwing me was if I get Exiftool to show me the data, it tells me LensID is set to "Unknown E-mount lens".  What I expect it must be READING is that LensID is set to some number that MEANS "Unknown E-mount lens", and was helpfully interpreting that for me?

Try running this command on one of the "Unknown" files
exiftool -G1 -a -s -LensID FILE

You will probably find that there isn't an XMP-aux:LensID but instead, it will be a Composite:LensIDComposite tags are tags derived from the values of other tags.  You'll see there are four different entries for LensID on that page.  The value is created from a variety of tags depending upon the source.  But Composite:LensID isn't a tag you can write to.

When you start diving into the mess that image metadata, you'll find a lot of tag names overlap and you'll want to know what group they belong to.  You'll find that your basic command to get info will usually start with exiftool -G1 -a -s or something similar.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Quentin

  • Newbie
  • *
  • Posts: 5
Re: Adding lens info to all files in a folder which don't have it
« Reply #8 on: August 19, 2019, 02:24:52 AM »
Thank you again.  Yes, you are correct.  Using those commands confirms that the LensID tag I was looking at is a composite tag.

There are a LOT of tags aren't there...  I think my image is made up of more data ABOUT the image, than the image itself...