When uploading to an ftp site, the original file create date seems to be lost, and I get the upload date instead. However, the Exif data in the file is correct. Is there a tool to batch change the created date from the Exif date?
The EXIF handling tool
exiv2 has a builtin option for this:
exiv2 -T rename image.jpg
sets the time of last file modification,
mtime, to the date stored in the EXIF metadata.
You asked for using the create time - but that is not used in Unix-like systems - and there are good reasons for that: https://unix.stackexchange.com/questions/27297/why-doesnt-nix-keep-track-of-file-creation-time
I'm pretty sure the time you call create time is actually
mtime - no problem there.
NAME exiv2 - Image metadata manipulation tool SYNOPSIS exiv2 [options] [action] file ... DESCRIPTION exiv2 is a program to read and write Exif, IPTC and XMP image metadata and image com‐ ments. The following image formats are supported: [ ... ] mv | rename Rename files and/or set file timestamps according to the Exif create time‐ stamp. Uses the value of tag Exif.Photo.DateTimeOriginal or, if not present, Exif.Image.DateTime to determine the timestamp. The filename for‐ mat can be set with -r fmt, timestamp options are -t and -T. [ ... ] -T Only set the file timestamp according to the Exif create timestamp, do not rename the file (overrides -k). This option is only used with the 'rename' action. Note: On Windows you may have to set the TZ environment variable for this option to work correctly.
-t to do the opposite.
Assuming, as mentioned by 'Volker Siegel', that you probably mean mtime, I would simple use exiftools builtin function..
$ exiftool "-DateTimeOriginal>FileModifyDate" test.jpg
this will take the "exif field "DateTimeOriginal" information and use it to set the filesystems modified date/time info of the file "test.jpg".
$ ls -la test.jpg -rw-r-----@ 1 user 18329968 2432451 14 Out 17:57 test.jpg $ exiftool -DateTimeOriginal test.jpg Date/Time Original : 2015:10:09 13:29:58 $ exiftool "-DateTimeOriginal>FileModifyDate" test.jpg 1 image files updated $ ls -la test.jpg -rw-r-----@ 1 user 18329968 2432451 9 Out 13:29 test.jpg
ExifTool can read and manipulate most EXIF information, including extracting the Date/Time Original or Create Data EXIF tags. You can use this information to rename the files or change their timestamps. For example:
find -name '*.jpg' | while read PIC; do DATE=$(exiftool -p '$DateTimeOriginal' $PIC | sed 's/[: ]//g') touch -t $(echo $DATE | sed 's/\(..$\)/\.\1/') $PIC done
This will find all JPG files in the current directory and update the timestamps.
If you want to also give those files a name based on that date (this tends to come in handy) then also add
mv -i $PIC $(dirname $PIC)/$DATE.jpg before the
ExifDate2FS tool will do this.
pip install exifdate2fs exifdate2fs /opt/folder_with_your_photos/