Useful ExifTool commands

When editing metadata of single image files I usually use my graphical metadata editor Verso. But when it comes to working with lots of files en masse, like shifting the date of all images in a directory by two hours, nothing beats the command line. ExifTool is great for this. Here is a random collection of handy commands.

Modifying multiple tags simultaneously

Set the XMP Creator and Rights tags of all files in the current directory to the same value with one single command.

$ exiftool -XMP-dc:{Creator,Rights}='Martin Hoppenheit' .

Copying one tag to another

Copy the EXIF date/time of all files in the current directory to their respective XMP Date tag with the < operator.

$ exiftool '-XMP-dc:Date<DateTimeOriginal' .

Editing tags with regular expressions

Modify the XMP Description tag of all files in the current directory using Perl regular expressions. This works by copying the tag to itself and modifying the content on the way.

$ exiftool '-XMP-dc:Description<${XMP-dc:Description;s/foo/bar/g}' .

Searching in tags

List all files in the current directory which contain the strings ‘Laura’ or ‘Martin’ in their XMP Description tag, or all files that were made with a specific camera model. You can use pattern matching with regular expressions or any other kind of Perl logic expression.

$ exiftool -if '$XMP-dc:Description =~ /(Laura|Martin)/' -FileName -T .
$ exiftool -if '$Make eq "Jolla"' -FileName -T .

Shifting date/time values

Increment the EXIF date/time of all files in the current directory by six hours.

$ exiftool -DateTimeOriginal+=6 .

Renaming files based on tags

Rename all files in the current directory based on their XMP date. This works by copying the value of the XMP Date tag to the special FileName tag with the < operator. The -d option specifies the date format (which in this case effectively is the file name format), the %%-c pattern adds a file counter if there are two or more files with the same XMP date, the %%e pattern symbolizes the original file name extension.

$ exiftool '-FileName<XMP-dc:Date' -d %Y%m%d-%H%M%S%%-c.%%e .

Printing all metadata

Print all metadata of all files in the current directory. Include duplicate and unknown tags, prefixed by each tag’s location group name (EXIF, XMP, …) and an additional prefix marking duplicate tags (Copy1, Copy2, …).

$ exiftool -a -U -G0:4 .

Deleting all metadata

Delete all metadata (or only the XMP metadata) of all files in the current directory.

$ exiftool -all= .
$ exiftool -XMP:all= .

Custom output formatting

Apply a format string with the -p option. Compare the following default output in the first with the customized output in the second example. This is particularly useful for piping to the sort command or similar things.

$ exiftool -DateTimeOriginal -FileName .
======== ./foo.jpg
Date/Time Original  : 2013:12:12 14:20:39
File Name           : foo.jpg
...

$ exiftool -p '$DateTimeOriginal - $FileName' .
2013-12-12 14:20:39 - foo.jpg
...