Author Topic: Assigning various date formats to different tags in single command line  (Read 580 times)

tommyzebman

  • Jr. Member
  • **
  • Posts: 24
When I try to do this, all date tags have the same format based on the last format read (I guess).

An example:

exiftool -progress -d %Y  "-copyright<Copyright $datetimeoriginal - Bill Jones.  All rights reserved." -d %Y%m%d  "-usercomment<datetimeoriginal" "D:\Temp\! Source"

Both date based tags use  %Y%m%d.

Is there a simple solution?

Thanks.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17049
    • ExifTool Home Page
Re: Assigning various date formats to different tags in single command line
« Reply #1 on: February 21, 2019, 12:03:12 PM »
The -d option applies to all date/time tags.  Formatting different tags differently can be done with the advanced formatting feature.  For example:

exiftool -progress "-copyright<Copyright ${datetimeoriginal;DateFmt("%Y")} - Bill Jones.  All rights reserved." "-usercomment<${datetimeoriginal;DateFmt("%Y%m%d")}" "D:\Temp\! Source"

- 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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4075
Re: Assigning various date formats to different tags in single command line
« Reply #2 on: February 21, 2019, 12:12:20 PM »
<deletes long detailed explanation because I'm too slow and Phil's too fast>

Also, if you have a lot of date tags you're working with, you can use the -d (dateFormat) option to format the majority of them, and then use the Advanced Formatting Helper function, DateFmt, on a per tag basis, though that would require the additional use of the -n (printConv) option hashtag option to negate the -d on a per tag basis.

exiftool -progress -d %Y "-copyright<Copyright $DateTimeOriginal - Bill Jones. All rights reserved." <insert more %Y Tag copy operations> "-usercomment<${datetimeoriginal#;DateFmt('%Y%m%d')}" "D:\Temp\! Source"
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

tommyzebman

  • Jr. Member
  • **
  • Posts: 24
Re: Assigning various date formats to different tags in single command line
« Reply #3 on: February 21, 2019, 12:25:56 PM »
The -d option applies to all date/time tags.  Formatting different tags differently can be done with the advanced formatting feature.  For example:

exiftool -progress "-copyright<Copyright ${datetimeoriginal;DateFmt("%Y")} - Bill Jones.  All rights reserved." "-usercomment<${datetimeoriginal;DateFmt("%Y%m%d")}" "D:\Temp\! Source"

- Phil

This did not quite work.  It ran, but used default date format for both and spit out error message for each file.  Is there an additional command needed for Advanced Formatting feature?


OKAY:  This version worked.  Suggested by StarGeek   # after tag name and using single quotes around date format  '%Y'  ??

exiftool -progress "-copyright<Copyright ${datetimeoriginal#;DateFmt('%Y')} - Bill Jones. All rights reserved." "-usercomment<${datetimeoriginal#;DateFmt('%Y%m%d')}" "D:\Temp\! Source"

Never would have known that one.
« Last Edit: February 21, 2019, 12:47:05 PM by tommyzebman »

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4075
Re: Assigning various date formats to different tags in single command line
« Reply #4 on: February 21, 2019, 12:34:34 PM »
Change the double quotes after DateFmt to single quotes.
${datetimeoriginal;DateFmt('%Y')}
${datetimeoriginal;DateFmt('%Y%m%d')}
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17049
    • ExifTool Home Page
Re: Assigning various date formats to different tags in single command line
« Reply #5 on: February 21, 2019, 12:40:11 PM »
Change the double quotes after DateFmt to single quotes.

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