Author Topic: Double occurence of AFFINETUNEADJ tag in NIKON group => read/write problems  (Read 6491 times)

Jodi

  • Newbie
  • *
  • Posts: 8
Using RenameMaestro I get a bad result for the AfFineTuneAdj value
Using : "exiftool -a -s -nikon:affinetuneadj name.jpg"  I see the problem.
There are 2 Tags with the same name in the NIKON group.
The first one gives the wrong value RenameMaestro is getting.
The second one is OK and the good value I want.

How can I fix this ?
How can I copy the second value in the field of the first value for all photos in a specified Dir ?


image example (from NIKON D300) in attachment.
PC = System Windows 7
EXIFTOOL = v8.26

Thanks,
Jodi

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Hi Jodi,

I don't know why, but neither AFFineTuneAdj tag is 100% reliable.

You can read the value from the second one with -a -copy1:affinetuneadj, but unfortunately I haven't built in the ability to do this when writing.  I will add a patch so the following command will do what you want in exiftool 8.27 when it is released:

exiftool -tagsfromfile @ "-affinetuneadj<copy1:affinetuneadj" DIR

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

Jodi

  • Newbie
  • *
  • Posts: 8
Thanks Phil for your fast help, it works great.

I wanted to use this information in a complex rename for many files ... together with a lot of other EXIF information.
I have a syntax that I can use to extract all needed EXIF data but it is too much for 1 filename AND ... in the lens information I have a / that causes exiftool to create directories.
I found a post in the archive "Reply #1 on: May 12, 2010, 08:54:37 AM" how to deal with this and replace the / by an other character.
I will try to get it done ... .

Could it be an idea to add a function that enables replacing characters (or even better character strings) by new ones so thet we could use it directly in the command line for the display and rename.
... I also want to drop the " mm", " G", " G VR", " NIKON" ....  and so on to shorten the filename.
My rename string is now:
    exiftool "-filename<$lens _ $exififd:focallength $composite:aperture _AF$copy1:nikon:affinetuneadj _ $model _%f.%e" DIR
and the goal is to get at the end a shortened filename like :
    10-20_ 4-5.6 _ 10 F8 _AF+11 _ D300 _DS00240515.jpg
indicating Lens, then actual settings, then AF adjustment and finally the original name.

SUGGESTION:
A syntax like the next could be nice
    exiftool "-filename      -replace ' mm',' '   ' G',' '   ' G VR',' '   ' NIKON',' '   '/','_'       <$lens _ $exififd:focallength $composite:aperture _AF$copy1:nikon:affinetuneadj _ $model _%f.%e" DIR
where the replace execution runs from left to right so that all complex operations can be done at once.

Thanks again for your help and a great tool ! (the best geotagging and renaming tool I found on the net both used your tool ... I discovered afterwards)
Jodi



Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Hi Jodi,

Yes, user-defined tags are the way to do this.

I appreciate your suggestion, and understand why you made it.  User-defined tags are not all that easy to use.  But they have other advantages that would be very difficult to add to the command line interface.

- Phil


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

Jodi

  • Newbie
  • *
  • Posts: 8
Thanks for your answer Phil, I understand you want to keep it in the config file.

I used :
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        JVLens => {
            Require => 'Lens',
            ValueConv => '$prt[0] =~ s{/}{}; $prt[0] =~ s{mm}{}; $prt[0]',
        },
    },
);

and my JVLens gives the nice tag I want.
HOWEVER I need to pack multiple tags together to substitute with the ValueConv all what needs to be changed in the name.
I tried a lot of things but could not get it.
Something like :
            Require 'lens','exififd:focallength','composite:aperture','copy1:nikon:affinetuneadj','model'
is what I need ... but above syntax, and several others I tried, did not work.
Can you give me a hint how to pack several tags into 1 string that I can treat with a substitute command like:
            ValueConv => '$prt[0] =~ s{/}{}; $prt[0] =~ s{mm}{}; $prt[0]',

Thanks
Jodi

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Hi Jodi,

The syntax to use is:

Code: [Select]
    Require => {
        0 => 'Lens',
        1 => 'ExifIFD:FocalLength',
        2 => 'Composite:Aperture',
        3 => 'Copy1:Nikon:AFFineTuneAdj',
        4 => 'Model',
    },

and use $val[N] and $ptr[N] for the values, where N is the number (0 through 4) of the require'd tag above.

Note that tag names are case sensitive when used in the config file.

Also note that the composite tag will only be generated if all Require'd tags exist.

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

Jodi

  • Newbie
  • *
  • Posts: 8
Dear Phil

I have to disappoint you.
I figured out already the part about defining multiple tags (see your last post).
My problems is that I can't bring them together in 1 string to deliver them as combined output ... I do not know how ...   ???

After the
    Require => {
        0 => 'Lens',
        1 => 'ExifIFD:FocalLength',
        2 => 'Composite:Aperture',
        3 => 'Copy1:Nikon:AFFineTuneAdj',
        4 => 'Model',
    },

I can work with each one of them seperately like
    ValueConv => '$prt[0] =~ s{/}{}; $prt[0] =~ s{mm}{}; $prt[0]',
or
    ValueConv => '$prt[2] =~ s{/}{}; $prt[2] =~ s{mm}{}; $prt[2]',


 ... but I need to combine ALL the contend of the 5 tags in ONE variable
(for example $alldataforname) so that I can do the substitution of several characters on it
and return the output for use as part of a new filename.
How can I combine the 0 1 2 3 4 in one new variable
... and how can I do a replacement of several characterstrings in that new variable and send it as output ?

The replace-operation I need to do could look like:
    ValueConv => '$alldataforname =~ s{/}{}; $alldataforname =~ s{mm}{-}; $alldataforname',
(where I eliminate the / and replace the mm by -)

I tried all kind of things ... but combining variables did not work ... stupid me... ;-((

Thanks for your help,
Jodi




Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Hi Jodi,

I'll consider myself your Perl tutor... ;)

There are various ways to combine a bunch of variables into a single string:

my $t = "@val";  # combines all elements in the @val list, separated by spaces.

my $t = join '', @val;  # combines all elements in @val list, separated by nothing.

my $t = $val[0] . $val[1] . $val[2] . $val[3] . $val[4];  # join strings with concatination operator

my $t = "$val[0]$val[1]$val[2]$val[3]$val[4]";  # interpolate the variables in a string

Hence the well known Perl acronym: TIMTOWTDI (There Is More Than One Way To Do It)

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

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
One more little hint.

If you use the built-in variable $_ instead of $v, then you don't need to specify the variable for the substitution.  ie)

    ValueConv => '$_="@prt"; tr{ /}{}d; s{mm}{-}; $_',

(the tr above deletes spaces and slashes)

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

Jodi

  • Newbie
  • *
  • Posts: 8
Thanks Phil ... you are a good tutor !  ;) => I solved my problem  ::) with the next code :

# create "JodiLens" tag and strip to get something like " 10-20_f4-5.6 _ 10 F8 _AF+11 _ D300 " as output for rename
#
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        JodiLens => {
    Desire => {
#    Require => {
        0 => 'Lens',
        1 => 'ExifIFD:FocalLength',
        2 => 'Composite:Aperture',
        3 => 'Copy1:Nikon:AFFineTuneAdj',
        4 => 'Model',
    },
            ValueConv => '$_="$prt[0] _ $prt[1] F$prt[2] _AF+$prt[3] _ $prt[4]"; s{mm f/}{_f}; s{.0 mm}{};s{.0 _AF}{ _AF};s{AF+-}{AF-};s{NIKON }{};$_ ',
        },
    },
);

I needed to use $prt as the lens tag came out wong in the output using $val ("Lens" value "50mm f/2" came out as "50 50 2 2")

Thanks again
Jodi

Jodi

  • Newbie
  • *
  • Posts: 8
Hi Phil

Just finished finding a solution for the problem that windows does not accept " and < signs in names of files.
I want to share this with you and other people because it opens up the possibility to directly send all kind of arguments to exiftool ...
... and makes exiftool very flexible and efficient for use from within the FastStone  Image Viewer (= very good program to compare and manage photos ! ... I can recommend it  ;D) .

To do the rename in the CMD window one would use:
         exiftool -m "-filename<$JVLens _%f.%e" DIR
... however I always call exiftool from another application : FastStone.
I send the photos that need to be treated to the exiftool executable.
For this reason I should be able to rename a copy of the exiftool.exe to :
         exiftool(-m "-filename<$JVLens _%f.%e").exe
and call it from the application with the photos in attachment ....
(like I did for :   exiftool(-k -a -u -g1 -w .txt.jpeg).exe   nicely dumping all data in a txt file visible under faststone and ready to be opened there with notepad)

PROBLEM: .
Windows does not accept " and < signs and this filename can not be created !

SOLUTION:
When defining the call to an external program, one can define the parameters inide the Faststone application.
In a normal case I only used the default value
       (filename)
In this case I added all needed parameters with the next syntax :
       -r -"filename<$JVLens _%f.%e" (filename)
Note that I had to shift the - before the " in front of the word filename.
So the syntax is not the same as what is used in the CMD window of windows.

I hope this is helpful for somebody and thanks for all the time you invested in this exellent tool and in the help to solve my problem;
Jodi

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Hi Jodi,

Thanks for this note.  For regular Windows use, the solution is to put the arguments in the "Target" property of a Windows shortcut to exiftool.exe instead of in the .exe file name.

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