ExifTool Forum

ExifTool => Newbies => Topic started by: mdlr on April 21, 2018, 11:49:29 AM

Title: Output date in XML format
Post by: mdlr on April 21, 2018, 11:49:29 AM
Thanks, to Phil's help (https://exiftool.org/forum/index.php/topic,9103.0.html (https://exiftool.org/forum/index.php/topic,9103.0.html)), I am now able to extract the date in which the image was last modified, among others, using the following:

exiftool -echo "SourceFile,FileName,ImageWidth,ImageHeight,FileModifyDate" -r -p "/$directory/$filename,$filename,$imagewidth,$imageheight,$filemodifydate" assets/photo > _data/images.csv

I am trying to figure out how to format the date so that it outputs in XML format; e.g. 2018-04-21T07:59:12-07:00

Thanks in advance for any guidance.

Title: Re: Output date in XML format
Post by: StarGeek on April 21, 2018, 12:05:52 PM
You can change the date format with the -d option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat).  Also check the Filename and Directory (https://exiftool.org/filename.html#codes) page for various date codes.
Title: Re: Output date in XML format
Post by: mdlr on April 21, 2018, 01:46:22 PM
Quote from: StarGeek on April 21, 2018, 12:05:52 PM
You can change the date format with the -d option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat).  Also check the Filename and Directory (https://exiftool.org/filename.html#codes) page for various date codes.

Thank you. However, I am having a hard time figuring out the syntax. Here's what I have tried:

exiftool -echo "SourceFile,FileName,ImageWidth,ImageHeight,FileModifyDate" -r -p -d %Y-%m-%dT%H:%M:%S-%z  "/$directory/$filename,$filename,$imagewidth,$imageheight,$filemodifydate" assets/photo > _data/images.csv

This gives me a file not found error for "%Y-%m-%dT%H:%M:%S-%z"

I'm also not sure how to add the T between date and time.

Title: Re: Output date in XML format
Post by: StarGeek on April 21, 2018, 06:45:04 PM
You inserted the -d %Y-%m-%dT%H:%M:%S-%z in between the -p and the format for that option.  Put it before the -p or after the format string and it should work.  And I don't think you need the dash before the %z, as it should be included, since technically it can also be a plus sign there as well.
Title: Re: Output date in XML format
Post by: mdlr on April 21, 2018, 09:04:43 PM
Quote from: StarGeek on April 21, 2018, 06:45:04 PM
You inserted the -d %Y-%m-%dT%H:%M:%S-%z in between the -p and the format for that option.  Put it before the -p or after the format string and it should work.  And I don't think you need the dash before the %z, as it should be included, since technically it can also be a plus sign there as well.

That did the trick. Thank you!