Additional to the GUI tools that are available to manage EXIF information in photos, there are also command line tools that can do this as well. Command line utilities allow you to script the processing of photos. The following shows how to manage photos using exiftool.
With the freely available exiftool, photo details can be exported as well as modified. The exiftool CLI can be downloaded from www.sno.phy.queensu.ca.
The following command shows how to read out the different date and time information from a JPEG photo in the current directory.
$ exiftool -time:all -a -G0:1 -s _DSC5260.JPG [File:System] FileModifyDate : 2015:12:04 22:39:18+01:00 [File:System] FileAccessDate : 2015:12:04 22:43:10+01:00 [File:System] FileInodeChangeDate : 2015:12:04 22:39:18+01:00 [EXIF:IFD0] ModifyDate : 2015:12:01 08:24:41 [EXIF:ExifIFD] DateTimeOriginal : 2015:12:01 08:24:41 [EXIF:ExifIFD] CreateDate : 2015:12:01 08:24:41 [MakerNotes:Sony] SonyDateTime : 2015:12:01 08:24:41 [EXIF:IFD1] ModifyDate : 2015:12:01 08:24:41
The above command lists all time relevant information (-time:all) for the given JPEG file. With the -a option, duplicate tags are shown as well. Instructing exiftool to print out the tag name and group name of each tag is done using the “-G0:1” option. The output as shown above shows the tag name as the second column while the first column contains the group of the tag in brackets. The tag names are needed later on to set or copy the information from one to the other. A short output format is produced with the “-s” parameter.
The tags listed with the group “[File:System]” show the filesystem information of the file. This date information can easily be lost when files are copied, or rotated from portrait to landscape. Depending on the settings and behaviour of the image viewer used, this can mess up the order of the photos. The groups starting with “[EXIF:…]” show information that is stored inside the JPG file as EXIF (EXchangeable Image File format) data.
To copy, for example, the date that is shown with the tag “DateTimeOriginal” to the modification date (tag: “FileModifyDate”) of the file (for sorting in the file explorer) the following command can be used
exiftool '-DateTimeOriginal>FileModifyDate' _DSC5260.JPG 1 image files updated
The format of the copy instruction is the following. Both examples show the same result.
-SRCTAG>TAG -TAG<SRCTAG
As the example above shows, the copy operation can be defined in two different ways. The operator between the tags indicates the direction of the copy operation.
Processing multiple photos
Processing multiple JPEG files and copying the EXIF date to the files’ modification date can be done with a few more options. The “-r” option processes directories recursively, while the “-ext .JPG” option instructs exiftool to process only JPEG photos.
exiftool '-DateTimeOriginal>FileModifyDate' -ext .JPG -r ./ 1 directories scanned 37 image files updated
The path at the end of the command line defines the start path where exiftool starts looking for files.
Backup and restore
By default exiftool creates a backup of every file modified. Before a file is modified a copy is created with the suffix “_original”. After successful processing of the files, the backup files can be conveniently deleted using the following command with the “-delete_original” option.
$ exiftool -delete_original -ext .JPG -r ./ 1 directories scanned 37 image files found 37 originals will be deleted! Are you sure [y/n]? y 37 original files deleted
In case the modification was not successful or did not provide the expected result, the backup files can be restored in a similarly convenient way.
$ exiftool -restore_original -ext .JPG -r ./ 1 directories scanned 37 image files found 37 image files restored from original
Prepare photos for sharing
Many devices store more and more meta information in photos. Sharing those photos in social networks might reveal information many users are not even aware of. As an example, smartphones not only store the name and model of the smartphone but also date, time and location information. This could allow tracking the whereabouts of the smartphone owner.
With exiftool all the meta information like EXIF and more can be removed with one simple command. The first command shows how to remove all meta information from a single file.
exiftool -all= _DSC5260.JPG 1 image files updated
The exiftool is a mighty utility and managing JPEG files is just a tiny peek into its functionality. To find out more about what it can do, check out the exiftool Application Documentation.
Read more of my posts on my blog at https://blog.tinned-software.net/.