Main Menu

Output date in XML format

Started by mdlr, April 21, 2018, 11:49:29 AM

Previous topic - Next topic

mdlr

Thanks, to Phil's help (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.


StarGeek

You can change the date format with the -d option.  Also check the Filename and Directory page for various date codes.
* 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).

mdlr

Quote from: StarGeek on April 21, 2018, 12:05:52 PM
You can change the date format with the -d option.  Also check the Filename and Directory 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.


StarGeek

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

mdlr

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!