Canon Lens Serial Number string

Started by roxie380, December 04, 2012, 05:17:39 PM

Previous topic - Next topic

roxie380

Phil,

I currently have the exiftool.exe, lens.ExifTool.exe, and ExifToolGUI.exe all in the C:\ directory.

And when I run the following command line, the config file works just fine:  C:\exiftool -config lens.Exiftool_config -g1 -w txt 7Dtest4.CR2

You said earlier that I really don't need the -config option, so let me try this without it and see if the tool still produces the correct result.

Oh, I'm calling the -g1, -h, -config, etc. "switches", I guess they are options...........

roxie380

Phil,

I think this has something to do with the config file not loading.  I changed the command line to:  C:\exiftool -g1 -w txt 7Dtest4.CR2 and did not get the new entry.  The file lens.ExifTool_config is in the same location as the exiftool.exe

This have anything to do with the Environment variable you mention in the FAQ #11?

Phil Harvey

I think you weren't paying attention or didn't understand what I was trying to say, so I'll be explicit:

In a cmd.exe window, type these commands:

cd c:\
rename lens.Exiftool_config .ExifTool_config


Then try again.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

roxie380

Phil,

Yep, I got that.

I'm in Windows 7 and am trying to figure out how to get to a command line window ---- been years.

So, since I was using the -config option, as you say in your documentation, any file name will work, but for it to run without that option, the file has to be renamed starting with the "."

Give me a few minutes..................

Phil Harvey

Yes. The config file name must start with a ".".

I'm confused.  I though you were already running exiftool commands in the command-line window.  You do the "rename" command in the same window.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

roxie380

Phil,

I've been brain-washed by Windows for so long.

I was running the command in the Windows "Run" line - just filling in the string in the "Run" window.

Man, took me a while to remember "cmd" ----- sorry.

But ----- HORRAY ------- this works so well now.   And, yes, it works in the GUI tool, too.  Plus, I'm so glad you told me how to get it into the Canon group  - I guess I shouldn't ask how to reorder those entries ---

Sorry this has taken so much of your time today.  Thank you so much for your help.

Now, I need to go to all my lenses and add them into the config file.

This is so cool..............Thank you again,


roxie380

Phil,

Reflecting on what we've done today, it looks to me like the conf file basically looks for a value, the ASCII, finds it and inserts the new value in a new Tag called "My Lens Serial Number" and then puts that in the Canon group.

Just curious, was there a way to find the existing and replace it in the existing Tag "Lens Serial Number" and not create a new Tag?  Or if it can be done, is it not considered good programming to mess with existing tags?

Probably over-thinking this......

Phil Harvey

Yes, you can override the definition of any tag if you want, but I don't suggest this.

The Composite tags are designed to allow you to take modify and combine the values of one or more other tags, so they are able to do what you want.  I don't even really like the idea of changing the group of a Composite tag to look like it came from somewhere else -- this is the first time anyone has ever requested this -- but mine is not to reason why...

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

roxie380

Phil,

Thanks.  Guess I was just thinking before I realized you could display the Composite in the GUI.

Just out of curiosity, in our example, how would your actually replace the LensSerialNumber with the actual serial number - just for my education in coding a "find and replace" example.

Also, you have no idea how long it took me to add two additional lenses in the config file.  I was using the tab key to get over to where you had put the first two entries.  Then nothing worked.  So, I finally used the space bar to move over and the two additional lines worked as well as the original lines.  Now, all my lenses show the actual serial numbers.  (Except of the little Nifty Fifty plastic guy that shows an all 0000000000 number - guess it doesn't have an internal serial number.

Thanks




Phil Harvey

Quote from: roxie380 on December 06, 2012, 07:06:09 PM
Just out of curiosity, in our example, how would your actually replace the LensSerialNumber with the actual serial number - just for my education in coding a "find and replace" example.

The easiest way is to copy the existing definition from the appropriate ExifTool library module and put it into the config file in the proper section, then modify it for your devious means.

QuoteAlso, you have no idea how long it took me to add two additional lenses in the config file.  I was using the tab key to get over to where you had put the first two entries.  Then nothing worked.

Odd.  Tabs are fine in Perl.  This should have worked.  Somehow your text editor was doing something else funny.  Perhaps your editor wasn't using the standard ASCII tab character.  There are a number of invisible UTF-8 characters which definitely would cause problems.  This is a big problem for OS X users because if you cut and paste code examples from here with Safari, you get a bunch of UTF-8 non-breaking-spaces instead of standard ASCII space characters, and these cause syntax errors in the code.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

roxie380

Phil,

Devious?  Well, we've gone this far, where do I find the ExifTool library module and where is the correct place in the config file?  Do you have an example somewhere I could look at?

You know, I have no idea about the tab vs space characters - I even edited the file and used the command window to rename it again just in case that was the problem.

What a day - I've learned so much - sorry it took so many messages and replies.

Thanks very much!

Phil Harvey

The library modules are included in all ExifTool distributions, but they aren't very easy to find in the Windows or Mac versions.  Look in the "lib/Image/ExifTool" directory in the full distribution, or you can browse them online here.  Click on the module, then click on the "Source" link to view the source code.  The definitions are added to the config file in exactly the same way as the ones in the example config file.  And if you want to get into all of the details, the lib/Image/ExifTool/README file documents the meanings of everything in these tables.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

roxie380

Phil,

Thanks so much for your help.

I don't know if anyone else have found this interesting (lots of views) but I certainly have learned a lot with your help (and patience).

Who knows what Canon may do with other upgrades.

Thank you!