Newbie wants to improve his Exiftool Program

Started by Archive, May 12, 2010, 08:54:23 AM

Previous topic - Next topic

Archive

[Originally posted by djpaige9 on 2008-07-26 22:52:57-07]

I have a DOS .bat file that calls exiftool, and it does what I want on a single file ... it copies certain information from a Nikon .nef file in one folder (where the originals are stored) to a .jpg with the same name (except for the .jpg part) in a different (output) folder. Great! Now, I want a program that can do this on every .jpg file in the output folder, copying the info from the related .nef file in the original folder.

Here is my code to perform this task on a single .jpg file. Your suggestions are appreciated.

set export="k:\photos\dsc_4163.jpg"

set origfile="d:\nikon pictures\2008 03 21\dsc_4163.nef"

REM DELETE ALL METADATA FROM FILE

"c:\program files\exiftool\exiftool.exe" -k -all= %export%

REM COPY METADATA FROM NEF FILE

"c:\program files\exiftool\exiftool.exe" -k -TagsFromFile %origfile% -all:all %export%

REM COPY GPS AND IPTC FROM TEMP FILE

"c:\program files\exiftool\exiftool.exe" -k -TagsFromFile %origfile% -gps:all %export%

"c:\program files\exiftool\exiftool.exe" -k -TagsFromFile %export%_original -iptc:all %export%

del %export%_original"

--

Paige

Archive

[Originally posted by exiftool on 2008-07-27 10:14:23-07]

Hi Paige,

First, you seem to be copying GPS from the NEF image instead of from the
source JPG image.  Is this what you wanted?  I'll assume you wanted to
copy GPS from the JPG.  If so, the command to do everything you want
to all files in a directory could look like this:

set jpgdir="k:\photos"

set nefdir="d:\nikon pictures\2008 03 21"

"c:\program files\exiftool\exiftool.exe" -all=
-tagsfromfile %nefdir%/%%f.nef -all:all
-tagsfromfile @ -gps:all -iptc:all
-overwrite_original %jpgdir%

This single command should do everything that your batch file
did before, plus it will work on either a single file or a full
directory of images.

Note that the directory separator may be either backslashes or
forward slashes -- it doesn't matter in the Windows version
which one you use in the exiftool arguments.

- Phil

Archive

[Originally posted by djpaige9 on 2008-07-27 13:06:15-07]

Thanks for the quick reply, I'll give it a try. Yes, I believe I want to copy the GPS from the NEF and the tags/keywords from the jpg. Its a long story, based upon my trying to use Exiftool to work around a bug in the way Photoshope Elements converts RAW to JPG for Nikon .nef files.

 

Paige

Archive

[Originally posted by djpaige9 on 2008-07-27 15:17:40-07]

Clearly, your code works as advertised. But I'm hoping you can explain to me why it works, cause I wanna learn. Inquiring minds want to know, and all that. Here's my guess and attempt at explanation.

The situation is that after I use Photoshop Elements to export my .nef to a .jpg, because of a Photoshop Elements bug, the .jpg contains Image Description, GPS, and IPTC information, but the EXIF camera information and maker notes has disappeared (it is not in the .jpg file). The .nef contains the rest of the EXIF, but not the GPS and not the IPTC. Thus my need to combine the metadata from the .nef and exported .jpg.
 

So, in your code, -all= will remove all the metadata from the .jpg and we will re-create the metadata properly. This -all= also creates a .jpg_original file. (Is that correct?) Then, the -tagsfromfile %nefdir%/%%f.nef -all:all appears to copy all metadata from the .nef to the .jpg. So far, I think I understand, but after that I'm guessing. Next, your code has a second -tagfromfile ... does this cause information to be copied from the .jpg_original file that was create by -all=?? If so, does the command -gps:all copies the GPS information from .jpg_original to the new .jpg?
 

What does the @ do?

Thanks!

Paige

Archive

[Originally posted by exiftool on 2008-07-27 15:31:54-07]

With the -overwrite_original option, the .jpg_original
file is not created.  Instead, the file is written to a temporary file,
then renamed to replace the original file if the write is successful.
This allows tags to be extracted from the original file with the
"-tagsfromfile @".  The "@" is just a symbol to represent
the original file.  (You could also use "%d%f.%e", but "@" is just
shorter.)

You can copy tags from as many different files as you
want in a single command, and here we are just copying from 2
different files. After each -tagsfromfile option, any
tags on the command line (up to the next -tagsfromfile)
are copied from the specified file.  So in this case, since
"-iptc:all" and "-gps:all" come after "-tagsfromfile @",
these tags are copied from the original file.

I hope this makes sense, I know this can seem a bit complex.
It is all explained in gory detail in the -tagsfromfile
section of the application documentation.

- Phil

Archive

[Originally posted by djpaige9 on 2008-07-30 22:16:39-07]

Thanks for the explanation. I did try reading through the docs, but there's just too much there for me to absorb at once, and I learn better by looking at actual code examples anyway.

Archive

[Originally posted by djpaige9 on 2008-08-09 22:32:49-07]

Follow-up question:

 
This is a rather minor matter, but my .jpg photo, before I run the Exiftool code you provided, appears in Windows Explorer (Windows XP Home) with the proper value in the column Date Picture Taken. After I run the Exiftool code, the Windows Explorer column Date Picture Taken is now blank, even though the proper information appears to be in the new .jpg file.
 

 
Is this a bug in Windows Explorer, or is there some way to modify this code so that Windows Explorer shows the proper date/time in Date Picture Taken? I can post the original .jpg and associated .nef files if that will help.

Thanks again!

Archive

[Originally posted by exiftool on 2008-08-15 11:48:08-07]

I'm not sure what Explorer is using in for the Date Picture Taken
information.    I have XP, but don't know how to display this
information.  If you tell me how to do this, I can run some tests
myself.

 - Phil

Archive

[Originally posted by djpaige9 on 2008-08-15 20:20:28-07]

Thanks for the offer of help. To have Windows Explorer display the Date Picture Taken, switch to Details view, then right-click on Name (or any other column heading), then select More down at the bottom and then check Date Picture Taken.

But I think the problem I am having actually has nothing to do with the Exif information or Exiftool. The problem is that Flickr Uploadr doesn't seem to use "Date Picture Taken", even though it says it uses that field. Instead, it uses the Windows field "Date Modified", which is different.

Sigh! It doesn't appear I can change the Windows field "Date Modified".

Archive

[Originally posted by exiftool on 2008-08-17 14:25:37-07]

You can change any of these fields with exiftool.  All you
have to do is figure out what tags correspond to these
Windows fields.  Try changing the "Date Modified" in
Windows, then use "exiftool -a -G1 -s" to see what was
changed, then use exiftool to write this tag.

When I get a chance, I will try to test this on my PC.

 - Phil

Archive

[Originally posted by djpaige9 on 2008-08-19 14:32:59-07]

Actually, I figured out what was going on with Flickr Uploadr.

Seems that if there is an FileModifyDate tag and an XMP tag regarding when the file was modified, Flickr Uploadr apparently used the most recent time. So, not knowing that the XMP tag was there, I was modifying FileModifyDate and it didn't seem to help. Once I used Exiftool to get rid of the XMP tag, my problem was solved.

Thanks again.