Suggestion for changing the ExifTool output date mask

Started by polaris6262, February 15, 2022, 06:10:00 PM

Previous topic - Next topic

polaris6262

ExifTool currently uses YYYY:MM:DD for all its date output, for example in file date/time:

File Modification Date/Time     : 2022:02:15 13:28:41-05:00
File Access Date/Time           : 2022:02:15 13:29:56-05:00
File Inode Change Date/Time     : 2022:02:15 17:05:45-05:00


and also archive date/time:

Zip Modify Date                 : 2022:02:14 19:30:30

This format cannot be used directly in commands under UNIX/Linux:

$ date --date='2022:02:15 13:28:41-05:00'
date: invalid date '2022:02:15 13:28:41-05:00'


It is necessary to change it to a hyphen ('-') either manually at the command prompt or programmatically in shell scripts before it can be used for conversions:

$ date --date='2022-02-15 13:28:41-05:00'
Tue Feb 15 01:28:41 PM EST 2022


The slash ('/') also works but as this is also the directory separator under UNIX, I believe a hyphen is the better choice.

This isn't such a big problem, but I do use the file date/time output rather extensively in my script code and I was noticing while improving it how many times I had to do ExifTool date editing.

Thank you for taking this into consideration.

Bernard Michaud

StarGeek

Use the -d (-dateFormat) option to format the date/time output as you want.  See Common Date Format Codes for the codes.

C:\>exiftool -time:all -G1 -a -s -d "%Y-%m-%d %H:%M:%S" y:\!temp\Test4.jpg
[System]        FileModifyDate                  : 2002-11-23 04:52:03
[System]        FileAccessDate                  : 2022-02-15 16:57:51
[System]        FileCreateDate                  : 2022-02-04 08:25:49
[IFD0]          ModifyDate                      : 2022-02-15 16:57:01
[ExifIFD]       DateTimeOriginal                : 2022-02-15 16:57:01
[ExifIFD]       CreateDate                      : 2022-02-15 16:57:01
* 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).

polaris6262

Many thanks for your answer, this was exactly what I needed. I should have known that there would be such an option. I did delve through the ExifTool documentation way back when I first started discovering this staggeringly useful software, but I think now is the time to reacquaint myself with it.