1

To set the file modification date of images to the exif date, I tried the following: exiftool '-FileModifyDate<DateTimeOriginal' image.jpg But this gives me an error about SetFileTime. So maybe exiftool cannot do it in linux.

Can I combine exiftool -m -p '$FileName - $DateTimeOriginal' -if '$DateTimeOriginal' -DateTimeOriginal -s -S -ext jpg . with "touch --date ..."?

2 Answers2

2

See this Exiftool Forum post.

The command used there is (take note of the use of backticks, not single quotes):

touch -t `exiftool -s -s -s -d "%Y%m%d%H%M.%S" -DateTimeOriginal TEST.JPG` TEST.JPG  

But I'm curious about your error. Exiftool should be able to set the FileModifyDate on Linux (though FileCreateDate is a different story). What version of Exiftool are you using (exiftool -ver to check)?

Another possibility is that the DateTimeOriginal tag is malformed or doesn't have the full date/time info in it.

StarGeek
  • 4,948
  • 2
  • 19
  • 30
  • `exiftool test.jpg / /ExifTool Version Number : 10.23 /File Access Date/Time : 2016:11:06 21:44:15+01:00 /File Permissions : rwx------ /Modify Date : 2015:08:21 18:51:28 /Exif Version : 0230 /Date/Time Original : 2015:08:04 10:00:35 /Create Date : 2015:08:04 10:00:35 ` –  Nov 07 '16 at 12:13
  • 1
    the reason why exiftool does not work is that the pictures are on a samba share in my NAS. –  Nov 07 '16 at 12:17
0

FWIW, StarGeek's answer was a great pointer in the right direction, but it did not work for me: many of my photos were reported to have "Invalid EXIF text encoding" (no obvious difference compared to those that were "fine"), even though exiftool somefile.jpg would clearly output a valid "Modify Date".

So this is what I did:

for i in *.jpg ; do d=`exiftool $i | grep Modify | sed 's/.*: //g'` ; echo "$i : $d" ; done

...to produce output like this:

CAM00786.jpg : 2013:11:19 18:47:27
CAM00787.jpg : 2013:11:25 08:46:08
CAM00788.jpg : 2013:11:25 08:46:19
...

It was enough for me to output the timestamps next to the file names, but given a little bit of date-time formatting, it could easily be used to "touch" the files to modify their filesystem timestamps.

Tomislav Nakic-Alfirevic
  • 10,017
  • 5
  • 38
  • 51