Manage photo EXIF data via terminal

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.

Advertisements

The following command shows how to read out the different date and time information from a JPEG photo in the current directory.

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

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.

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.

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.