News:

2023-08-10 - ExifTool version 12.65 released

Main Menu

Exif User Comment Edit

Started by Winston, February 09, 2018, 06:45:48 AM

Previous topic - Next topic

Winston

I have a software program that I am using that uses the exif user comment for the data field. I would like to edit the date and time in the user comment(see highlighted area on screenshot) to match the datetimeorignal tag without changing the rest of the comment. Can you tell me what I can do?

I have also attached one of the photos.

Phil Harvey

You can do this with the advance formatting feature and this rather complicated command:

exiftool "-usercomment<${usercomment;s/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .M/$self->GetValue('DateTimeOriginal')/e}" -d "%Y-%m-%d %l:%M:%S %p" FILEorDIR

The only thing is that when you are done the UserComment will be formatted properly, whereas in the original it is written incorrectly (lucky ExifTool is so smart, or it wouldn't have been read it in the first place).

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

Winston

I am not getting a date and time. See attached

Winston

It appears that it would also need to be formatted the same way, because the software no longer recognizes  the keywords in the comment.

Phil Harvey

I take it you figured out the problem resulting in the Screen.PNG output?  What was it?

If so, and the software requires an incorrectly written EXIF:UserComment, then you will need to override the ExifTool definition with a user-defined tag to be able to write it improperly like this.

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

Winston

No, I didn't figure out the problem in the screen.png. It is just when the comment was changed the software looked to the file modify date for a date instead of the incorrectly written EXIF:UserComment.

But the software does not see the keywords anymore that are in the correctly written EXIF:UserComment.

Winston

Ok, I tried it again with exiftool 10.78 now. It just removed the date completely from the usercomment.

StarGeek

Error in the date format string, I think.

Try -d "%Y-%m-%d %H:%M:%S %p" instead.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

I used %l instead of %H because it gives a 12-hour clock.  Didn't try to see if this works on Windows though. But even so, I don't understand the empty UserComment.

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

StarGeek

Ah.  I guess it doesn't work on windows then and the whole thing gets blanked.

C:\>exiftool -DateTimeOriginal -DateTimeOriginal# -d "%Y-%m-%d %l:%M:%S %p" "Y:\!temp\!abr\2016-04-20 19-39-36.jpg"
Date/Time Original              :
Date/Time Original              : 2016:04:20 19:39:36


On Windows it looks like it needs to be %I:
C:\>exiftool -DateTimeOriginal -DateTimeOriginal# -d "%Y-%m-%d %I:%M:%S %p" "Y:\!temp\!abr\2016-04-20 19-39-36.jpg"
Date/Time Original              : 2016-04-20 07:39:36 PM
Date/Time Original              : 2016:04:20 19:39:36
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

You're right.  It should have been %I (capital I).  I mis-read my documentation, but an odd coincidence that %l (lower case L) worked for me.  However, it only gives a single digit for times less than 10, so it wasn't the right one to use anyway, especially since it doesn't work in Windows.

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

Winston

Ok, I tested it and it did change the date now. But the software I am using does not see the keywords in the comment anymore. Apparently it need to have it in the same incorrect format that it was in before. Is there anyway to have exiftool keep it in the same format as before? I have attached a photo that was formatted by the software.

Phil Harvey

Yes.  As I mentioned, you need to create a user-defined tag to do this.  This config file will do it:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Exif::Main' => {
        0x9286 => {
            Name => 'UserComment',
            Format => 'undef',
            Writable => 'undef',
        },
    },
);
1; #end


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

Winston

I am not sure how to use the config file. Do you have somewhere I can learn how to use it?

Phil Harvey

The sample config file contains instructions and examples.

Also, you could search the Appliction documentation for "config".

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