ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: tommyzebman on February 21, 2019, 11:55:53 AM

Title: Assigning various date formats to different tags in single command line
Post by: tommyzebman on February 21, 2019, 11:55:53 AM
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.
Title: Re: Assigning various date formats to different tags in single command line
Post by: Phil Harvey 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
Title: Re: Assigning various date formats to different tags in single command line
Post by: StarGeek 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 (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat) to format the majority of them, and then use the Advanced Formatting Helper function (https://exiftool.org/exiftool_pod.html#Helper-functions), DateFmt, on a per tag basis, though that would require the additional use of the -n (printConv) option (https://exiftool.org/exiftool_pod.html#n---printConv) 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"
Title: Re: Assigning various date formats to different tags in single command line
Post by: tommyzebman on February 21, 2019, 12:25:56 PM
Quote from: Phil Harvey 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

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.
Title: Re: Assigning various date formats to different tags in single command line
Post by: StarGeek 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')}
Title: Re: Assigning various date formats to different tags in single command line
Post by: Phil Harvey on February 21, 2019, 12:40:11 PM
Quote from: StarGeek on February 21, 2019, 12:34:34 PM
Change the double quotes after DateFmt to single quotes.

Ooops.