Windows JPG Comment tag and date parsing in filename

Started by SailorGuy, February 17, 2015, 08:56:52 AM

Previous topic - Next topic

SailorGuy

I have two questions:

1.   What is the JPEG tag name for the "Comment" field that displays in a Windows JPG image file properties?  I tried "-Comment" which did set a Comment value in the metadata but it isn't the one that displays when you right-click a JPG file and click Properties on a Windows 7 system. 

I know there is a Tag Name Documentation reference guide, but I couldn't find the correct one that listed the various "comment" tags. 

2.   I want to set the DateTimeOriginal, FileCreateDate, and FileModifyDate date/time values based on the filename of a JPG file.  The filename has a date stamp as the first part but does not include a time stamp.

The filename standard is 20150213-[MCD]_Study_Abroad-001.JPG.

I want the time tag values to be "2015:02:13 12:34:56" with a YYYYMMDD date from the filename and a hardcoded time stamp of "12:34:56".

I can do it with a file processing loop in a shell script, but is there a way to parse the filename on the command-line and concatenate the hardcoded "12:34:56" time stamp?  I want to use a wildcard spec so I don't have to repetitively invoke ExifTool.  For example: Exiftool {commands to execute} 2015*.jpg

Here is my shell script code segment:

set FileSpec=C:\Photos\20150213-[MCD]_Study_Abroad-001.JPG
set Year=%FileSpec:~0,4%
set Month=%FileSpec:~4,2%
set Day=%FileSpec:~6,2%
set NewDate=%Year%:%Month%:%Day% 12:34:56
ExifTool -v2 -a –P -Overwrite_Original -args  -Comment="Scanned Photo" ^
-FileCreateDate="%NewDate%" -FileModifyDate="%NewDate%" -DateTimeOriginal="%NewDate%" ^
%FileSpec%

Thank you,

Sailor Guy


Phil Harvey

Quote from: SailorGuy on February 17, 2015, 08:56:52 AM
1.   What is the JPEG tag name for the "Comment" field that displays in a Windows JPG image file properties?  I tried "-Comment" which did set a Comment value in the metadata but it isn't the one that displays when you right-click a JPG file and click Properties on a Windows 7 system. 

Did you read FAQ 3?

Quote2.   I want to set the DateTimeOriginal, FileCreateDate, and FileModifyDate date/time values based on the filename of a JPG file.  The filename has a date stamp as the first part but does not include a time stamp.

The filename standard is 20150213-[MCD]_Study_Abroad-001.JPG.

I want the time tag values to be "2015:02:13 12:34:56" with a YYYYMMDD date from the filename and a hardcoded time stamp of "12:34:56".

There are many ways to do this.  The only complication is that your file names contain non-date digits, so I must remove them (here I do this by deleting the "-" and subsequent characters, but there are other ways) before copying to the date/time tag.

exiftool "-DateTimeOriginal<${filename;s/-.*//} 12:34:56" "-FileCreateDate<${filename;s/-.*//} 12:34:56" "-FileModifyDate<${filename;s/-.*//} 12:34:56" FILE

where FILE is one or more file and/or directory names.

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

StarGeek

#2
For your first question, try the XPComment tag. 

edit: wrong word
* 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).

SailorGuy

Re: Question 1 (Windows JPG Comment tag)

Thank you, StarGeek, for the "XPComment" tag.  That's the one I was looking for.

I had read FAQ 3 and tried the "-a -g1 -s" display - but I didn't see XPcomment in the list.

Re: Date Parsing

Phil, thanks for the filename date parsing command syntax.  I'm making progress but I'm not quite there.

The (3) AllDates (DateTimeOriginal (Date Taken), CreateDate, ModifyDate) tags changed, but not the (3) filesystem FileModifyDate, FileAccessDate, and FileCreateDate tags.  See the attached PDF for details.

Can Windows filesystem tags be changed?

Thanks,

Sailor Guy

SailorGuy

I'm having a problem calling EXIFTOOL from inside a Shell batch script when using the "-AllDates<${filename;s/-.*//} 12:34:56" syntax.  I'm sure it has to do with "escaping" the "<" symbol inside a BAT file...

To recap... my filename standard is 20150213-[MCD]_Study_Abroad-001.JPG

The following command works as expected when typed at a CMD prompt to reset the DateTimeOriginal, Createdate, and ModifyDate values by parsing the filenames' yyyymmdd date prefix:

ExifTool -v2 -a -P -Overwrite_Original -args -XPComment="Scanned Photo" "-AllDates<${filename;s/-.*//} 12:34:56" 19770901*.JPG

But the same command invoked in a shell .BAT script file fails.

I replaced the:

"-AllDates<${filename;s/-.*//} 12:34:56" syntax with

"-AllDates^^^<${filename;s/-.*//} 12:34:56" but it is ignored when the BAT script is run.

What is the correct redirection syntax when invoked from inside a shell BAT script?

Thank you,

Sailor Guy

StarGeek

Quote from: SailorGuy on May 24, 2015, 03:42:26 PM
I'm sure it has to do with "escaping" the "<" symbol inside a BAT file...

It shouldn't be.  I've used "<" in batch files many times without having to escape them.

I just renamed a file to match your example name "20150213-[MCD]_Study_Abroad-001.JPG", and created a batch file with your command in it, though I did remove the Overwrite_Original and used a direct path to the above file name.  It worked correctly.

Is there any other commands in your batch file?  Any percent signs, as those need to be doubled.

* 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).

SailorGuy

StarGeek,

Thanks for the prompt response.

Could you please attach the test batch file you wrote?  Maybe I'm missing something in the syntax.

Thank you,

Sailor Guy

StarGeek

Here's the link

https://www.dropbox.com/s/svxxyyrxb3a85ht/test.bat?dl=0

It's only one line, copy/pasted from your post, with the only change is a path to my test file and removal of Overwrite_Original
ExifTool  -v2 -a -P -args -XPComment="Scanned Photo" "-AllDates<${filename;s/-.*//} 12:34:56"  X:\!temp\z\20150213*
* 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).

SailorGuy

I must have had an extra character in my command string before.

It's working now!

Thanks,

Sailor Guy