Command line help to copy User Comment data

Started by FionaH, May 29, 2011, 04:09:08 AM

Previous topic - Next topic

FionaH

Dear Everyone, I am hoping one of you will take pity on me and provide simple instructions to do what I need.

I have a lot of family photos my children have carefully tagged & commented on over the years through a program called "swizzy photosmacker".  It was great and Windows XP would see the user comments & keywords so I could sort and search and everyone was happy.

I have discovered the Win7 does not want to do this!  In fact I cant find any software that will 'see' these EXIF/Metadata inputs except the original photosmaker software which I do not think is made/supported/updated anymore.  SO... before it ceases to run completely, I need to extract these comments & keywords and put them in more commonly accepted/used 'spots'. 

SO... what I really need (please) is a command line that will copy the data out of the "user comment" field (I'm not even sure how to find the keyword stuff, it doesnt show up in Irfanview at all which I tried but couldnt get my head around) and copy it into another suitable field.  Simple instructions would be very much appreciated.  (that said, I am competant at Windows, and basic cmd line stuff, being older than windows and even dos3.1 if any one else remembers those. Its just my days of programming are a long way past and I appreciate you experts!).

If anything in the request isnt clear, please let me know. 
Kind regards
Fiona

Phil Harvey

Hi Fiona,

Quote from: FionaH on May 29, 2011, 04:09:08 AM
called "swizzy photosmacker"

Surely you must be joking.  ;)

Quote
SO... what I really need (please) is a command line that will copy the data out of the "user comment" field (I'm not even sure how to find the keyword stuff, it doesnt show up in Irfanview at all which I tried but couldnt get my head around) and copy it into another suitable field.

Here are the steps:

1) Run this command on a swizzy image to see where it puts your metadata:

exiftool -a -G -s c:\images\swizzy.jpg

(assuming your image "swizzy.jpg" is in the "c:\images" directory)

2) Run the same command on an image containing metadata recognized by Windows 7 (you might be able to use Windows 7 to write the metadata to be sure it was written in a way that Windows 7 will accept it)

Both commands output metadata in the form:

[GROUP] TAG: VALUE

3) Run this command to copy metadata from the GROUP1:TAG1 determined in step 1 to the GROUP2:TAG2 determined in step 2:

exiftool "-group2:tag2<group1:tag1" c:\images

This command will copy the specified information to the locations required by Windows 7 for all images in the directory "c:\images".  You may add more arguments on the command line to copy more tag values in the same command if required.

I hope this helps.

- 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 ($).

bakedcookies

Sorry for bumping this old thread, but I believe this will do exactly what I need. I have an application that uses the EXIF data from the create date tag to determine when a photo was taken and link it to a record "call" in a database.

Below is a screen shot of a new camera's data (left) and the original camera's data (right)



as you can see the data on the left (new camera) is very limited. I need to call your utility from command line and grab the information in the Modify Date tag and insert it in a Create Date tag for my software to continue working. So far based on your example above I believe i need to do something like so:

exiftool "-group2:Create Date<group1:Modify Date" C:\images  -where c:\images is the location of multiple .jpg files.

what needs to go in the group2 and group1 fields? Will i be able to call this from a batch file when an end user clicks a shortcut? I am sure these answers are somewhere on here but I am experiencing a time crunch in deploying a new tablet with built in camera.

Thank you for your time and what appears to be an amazing application.

Phil Harvey

My advice to you is the same as above:  Run the command with -a -G -s on existing files to get the tag names and group names of the information you want to move, then run the command with "-group2:tag2<group1:tag1" to move the information.

You can run this from a .BAT file if you want.

- 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 ($).

RedYeti

This saved me when Picasa 3.9 managed to mangle the dates in hundreds of images. Luckily the dates were also stored as XMP (possibly because Lightroom had imported them, I've not checked)

I thought I'd post the command that was used in case it helps anyone else:

This simply updates the date which Picasa uses (the EXIF DateTimeOriginal) using the data from the XMP:CreateDate

exiftool "-EXIF:DateTimeOriginal<XMP:CreateDate" "c:\images"

FionaH

Hi, Phil, Fiona here again.  I haven't made much progress last two years on this project, but it is becoming URGENT as my photos are such a mess.  I'd bookmarked your response which was and have returned to it to execute... but....

1. Language issues
Ok, so I used the command exiftool -a -G -s c:\images\swizzy.jpg  as recommended and got gobbledegook for the XPKeyword and XPComment [tried to paste screen shot but didnt work].
Tried to copy contents of the tag anyway and got an error "Warning: Some character(s) could not be encoded in Latin - IMG_0935.jpg".  (and yes, the gobbledegook has been copied, bar some symbols from XPKeyword to Keyword and now shows in IPTC Keywords in XnView).

So I"m guessing there is a language barrier here... how do I determine what language the Keyword has been encoded in; and then translate it? 

2. NO data showing in exiftool although it exists
the Tag "UserComment" lists contents as "ASCII" in the above exiftool listing but in Xnview it shows in English as a detailed comment on the photo.
AND... this field now shows "ASCII" in xnview after trying to copy the contents of the XPKeyword tag to Keyword.  ie exiftool has lost/overwritten this tag too.

I would really appreciate help here as I have 10+years of photos with these comments from when my kids were young...  I can still read the data in Swizzy Photosmacker (it still runs) but dont want to have to manually copy/paste the comments out for 100's (1000's?) of photos.
Happy to take this offline if best - I am in Sydney so easy to call QLD if best.
Can probably provide copy of Photosmacker (!) if would help!?!  Only a small (<3Mb) file.

Look forward to hearing from you if at all possible.

Phil Harvey

Hi Fiona,

For both the character encoding problem and the UserComment "ASCII" problem, I would recommend upgrading to a more recent version of ExifTool before proceeding.  If you still have the problems, send me image samples and I'll take a look.  My email is philharvey66 at gmail.com

- 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 ($).


Phil Harvey

#8
Hi Fiona,

I got the sample, thanks.

Interesting.  Swizzy Photosmacker is really pretty buggy when it comes to writing EXIF metadata:

The problem with the EXIF UserComment is that the format is incorrectly set to "ASCII" instead of "UNDEFINED" as specified by the EXIF specification.

The problem with the XPComment is that it is stored in ASCII instead of Unicode as it should be.

The following config file will allow you to read both of these values:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Exif::Main' => {
        0x9286 => {
            Name => 'UserComment',
            Format => 'undef',
            Writable => 'undef',
            RawConv => 'Image::ExifTool::Exif::ConvertExifText($self,$val,1)',
            RawConvInv => 'Image::ExifTool::Exif::EncodeExifText($self,$val)',
        },
        0x9c9c => {
            Name => 'XPComment',
            Format => 'undef',
            Writable => 'int8u',
            WriteGroup => 'IFD0',
            ValueConvInv => '$self->Encode($val,"UCS2","II") . "\0\0"',
        },
    },
);


See the comments in the sample config file for instructions on how to use a config file.

With this config file installed, the following command will fix the format of these tags for all images in directory "DIR":

exiftool -tagsfromfile @ -xpcomment -usercomment DIR

But make sure that ExifTool is extracting the correct comments before applying this command to all your files.

- 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 ($).

FionaH

WOW you are a fantastic!!!!  Awesome!  :D :D :D

Could I presume & ask nicely for you to extend the 'config' file program to include the field 'XPKeywords' which are also scrambled, and seem to get more so when I run the exiftool.

Lastly, a minor thing to me, but just noticed that also, when I run the commands above that the 'Max aperture' field (shown in Windows 7) changes value for the sample photo I sent you.    Its not just a rounding change - it went from 2.9708536585...... to 2.96875 (five dec. places).  Means nothing to me, but thought I'd mention for others that may (or may not) be affected.

P.S. is there anything GUI that you would 'suggest' I can use to write my comments, keywords etc in the EXIF data that isnt buggy/prone to wiping out your data / losing your data?  I'm obviously going to need something better going forward. 

thanks, Fiona

Phil Harvey

Hi Fiona,

Here is the updated config file:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Exif::Main' => {
        0x9286 => {
            Name => 'UserComment',
            Format => 'undef',
            Writable => 'undef',
            RawConv => 'Image::ExifTool::Exif::ConvertExifText($self,$val,1)',
            RawConvInv => 'Image::ExifTool::Exif::EncodeExifText($self,$val)',
        },
        0x9c9c => {
            Name => 'XPComment',
            Format => 'undef',
            Writable => 'int8u',
            WriteGroup => 'IFD0',
            ValueConvInv => '$self->Encode($val,"UCS2","II") . "\0\0"',
        },
        0x9c9e => {
            Name => 'XPKeywords',
            Format => 'undef',
            Writable => 'int8u',
            WriteGroup => 'IFD0',
            ValueConvInv => '$self->Encode($val,"UCS2","II") . "\0\0"',
        },
    },
);


The max aperture won't change if you don't copy this tag (MaxApertureValue).  If you specify the tags to be copied as I did in the command I posted, then only these tags will be written and the max aperture won't change.  If you do copy MaxApertureValue, then it may change slightly due to round-off errors since it is only printed to 1 decimal place.

As far as the GUI goes, you could look into ExifTool GUI.

- 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 ($).

FionaC

Hi Phil,
FionaH here with a new login as I have no idea what email address the old account was under... plus a name change wont help ;-)

Astonishingly... 10 years later I have not yet 'fixed' this problem of my files; but 2025 IS THE YEAR!!!

So I've made good progress on copying the data from EXIF fields to XMP fields; except for the keywords.
These are coming across with two issues.

1. where there is more than one keyword in the XPKeywords field they are coming across as one string (as read by Adobe Bridge anyways)

2. At the end of the 'keywords' copied across, exiftool is adding a "." (full stop). Sometimes with a space; sometimes not.

I've read FAQ17 and tried a few things with the -sep command but not getting any visible/useable results.
Can you help?

THANK YOU  ;D

StarGeek

What is the command you are using? Can you provide a sample image? Also, make sure you are using CMD and not PowerShell, as PS has a lot of idiosyncrasies compared to every other command line.

The main problem with XPKeywords is that is it saved as a semicolon separated string, where keyword type tags such as Keywords and Subject are list type tags, meaning every single entry is completely separated from the others.

The basic command should be something like
exiftool -sep ; "-Subject<XPKeywords" /path/to/files/

Example. I use -sep ## in the last command to show that each keyword has been split into separate list entries and isn't a simple string the way that XPKeywords is.
C:\>exiftool -G1 -a -s -XPKeywords y:\!temp\Test4.jpg
[IFD0]          XPKeywords                      : Keyword 1;Keyword 2;Keyword 3

C:\>exiftool -P -overwrite_original -sep ; "-Subject<XPKeywords" y:\!temp\Test4.jpg
Warning: [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto [x2] - y:/!temp/Test4.jpg
Warning: [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto - y:/!temp/Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -Subject -XPKeywords -sep ## y:\!temp\Test4.jpg
[XMP-dc]        Subject                         : Keyword 1##Keyword 2##Keyword 3
[IFD0]          XPKeywords                      : Keyword 1;Keyword 2;Keyword 3

Exiftool won't add a random character to the end of the data. It either has to already be part of the data or it is part of the command. The dot might not be an actual dot but is instead something else. Exiftool will replace characters such as new lines with dots because they would otherwise mess up the formatting of the output.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

FionaC

Stargeek you are AMAZING!  Thank you, that has helped enormously.

1. hmmm not sure if I was using CMD or PS. I went into the 'settings' in CMD window and have changed the default profile to CMD...

2. I used exiftool -P -overwrite_original -sep " " "-Subject<XPKeywords" *.jpg to 'fix' most of the keywords into the Subject; YAY... they are now separate!

So... the main issue now is these random '.' that appear; mostly at the end of the keywords like this:
C:\1-TEMP\EXIFtool>exiftool -G1 -a -s -Subject -XPKeywords -sep ## *.jpg
======== IMGP1721.JPG
[XMP-dc]        Subject                         : Molly##lauren.
[IFD0]          XPKeywords                      : Molly lauren
======== IMGP1722.JPG
[XMP-dc]        Subject                         : dad.
[IFD0]          XPKeywords                      : dad
======== IMGP1723.JPG
[XMP-dc]        Subject                         : dad.
[IFD0]          XPKeywords                      : dad
======== IMGP1724.JPG
[XMP-dc]        Subject                         : Molly.
[IFD0]          XPKeywords                      : Molly

BUT... there is one very odd one and this is the output -
 C:\1-TEMP\EXIFtool>exiftool -G1 -a -s -Subject -XPKeywords -sep ## c:/1-temp/IMGP1720.jpg
[XMP-dc]        Subject                         : D.a.d...
[IFD0]          XPKeywords                      : Dad

So it looks like the original keyword is just 3 characters; but you can see in the Subject field several '.' have been added!

Any thoughts on this? [even a command to just delete '.' from any keyword would probably suffice!
Cannot thank you enough!

Phil Harvey

If you could attach IMGP1720.jpg (or send it to me privately: philharvey66 at gmail.com), we (or I) could take a look to see where these extra dots are coming from.

- 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 ($).