Exiftool Examples

2/14/2022by admin

ExifTool by Phil Harvey is a fantastic tool to edit the exif metadata on your pictures. It is especially useful when you have a lot of pictures to edit and have no desire to change metadata by hand.


Exiftool Tutorial Series. OVERVIEW This four-part series of video tutorials, created by Kathryn Gronsbell is focused on Exiftool, a command-line application that can read, write, and edit embedded metadata in files.

The exiftool by Phil Harvey has been described as the Swiss Army knife for file metadata manipulation and it certainly is that. For my purposes, I only needed a small subset of the functionality offered by exiftool (which for some reason I keep misspelling as ‘exitfool’). This example illustrates the dangers of leaving meta information on jpeg images. In this example, we use Exiftool to extract thumbnail embedded in a jpeg picture that has been cropped with Photoshop 7. Contribute to dimitargnikolov/pythonexiftoolexamples development by creating an account on GitHub. Type 'exiftool' followed by a SPACE on the cmd window. Drag and drop files and folders on the cmd window. (This saves you typing the full path names of the files/folders.) Press ENTER to view the metadata from the files you dropped. GIVE SOME EXAMPLES AND PICTURES HERE. Writing Metadata. MORE STUFF HERE (also explain shell quoting rules, path names, etc).

This post will be an ever growing list of useful exiftool commands and scripts.

Remove Exif Properties from Pictures

If you are uploading a picture to a public website, it would be wise to scrub any exif properties - especially if there are GPS exif properties. You can do this with the following command:

If you are in a directory with many pictures that you want to scrub the exif data from, you can use a wildcard to process them all:

Find Files Missing Exif Properties

You can quickly figure out if a picture is missing a particular exif property by running the following command. In this example, I want to see if my picture has the DateTimeOriginal exif property set:

If you have a folder of pictures to check, or even a folder contaning even more folders of pictures, you can simply replace /path/to/picture.jpg with /path/to/picture/directory/:

Exiftool Examples

The picture does not have the DateTimeOriginal exif property if its file name is returned.

Ryan M provides more insight into finding and fixing images with no exif dates.

Add CreateDate Exif Property to a Picture

If your picture was taken on June 29, 2007 at 1:38:55 PM, you can add the CreateDate exif property to your picture with the following command:

Add CreateDate Exif Property and Copy DateTimeOriginal Exif Property Value to It

I had a situation where many of my pictures did not have the CreateDate exif property but they did have the DateTimeOriginal exif property. I wanted the CreateDate exif property to have the same value as the DateTimeOriginal exif property. ExifTool’s if functionality makes this easy to fix:

ExifTool will always copy the original picture and then make its modifications. If you want it to overwrite the original picture, add -overwrite_original_in_place to the exiftool command line.


Writing 'FileName' and 'Directory' tags

By writing the FileName and/or Directory tags, ExifTool can beused to rename and/or move images into directories according to any informationcontained in the image. The most useful application of this feature is toorganize images by date/time, but any other tag value may also be used.

Writing the Directory tag moves a file to a specified directory. Thedirectory is created if it didn't already exist.

Writing the FileName tag renames a file. If the new FileNamehas a directory specification (ie. contains a '/' character), thenthe file is also moved to the specified directory (see example 6 below). Existing files will not be overwritten.

The %d, %f, %e file name format codesmay be used to represent the directory, name and extension of the original filewhen specifying FileName and Directory tags via the command-lineinterface. (In a similar way to the -o, -w and-TagsFromFile options.) Also, %c may be used to add acopy number to the output file name to avoid collisions with existing filenames. Note that these codes must be escaped with an extra % ifused within a date format string. Modifiers may also be used to change thedefault behaviour of these format codes. See the-w option documentation fordetails.

When organizing files by date/time, use of the -d (date format)option is essential to specify a format for the file (and/or directory) name. The examples below demonstrate the use of this feature. Also, a quick referenceof common date format codes is included.

Exiftool Windows 10


Writing the FileName and/or Directory tags alone causes thefile to be renamed or moved, not copied. However, if any other tags are writtenat the same time, then the file is rewritten to the new destination and theoriginal file is left unchanged. (The only exception to this isFileModifyDate tag, which will not cause the file to be rewritten becauseit is the only other writable tag not representing meta information within thefile.) But if desired, the -overwrite_original option may be usedin this case to remove the original copy.

Conversely, the -o option may be used to force exiftool toalways create a copy of the file, even if no meta-information tags are written. To do this, a dummy file name or directory (to be overridden by theFileName or Directory tag) must be specified for the-o option. (See example 5 below.)

If the -d option is used, the unformatted date/time value mustbe valid (ie. in the form 'YYYY:mm:dd HH:MM:SS'), otherwise thedate formatting will fail and the file will not be renamed or moved.


1.exiftool -d %Y%m%d_%H%M%%-c.%%e '-filename<CreateDate' DIR
Rename all images in directory 'DIR' to names like'20060327_1058-2.jpg', with individual file names derived from thevalue of the CreateDate (plus a copy number with a leading '-' if afile with the same name already exists), and with the same extension as theoriginal image.
2.exiftool -d %Y-%m-%d '-directory<datetimeoriginal' image.jpg
Move 'image.jpg' into a directory with a name given byDateTimeOriginal, in the form '2006-03-27'.
3.exiftool '-filename<%f_$imagesize.%e' dir
This example uses an expression to add the image size to the name of all imagesin directory 'dir'. For example, this would remame a 640x480 imagecalled 'image.jpg' to 'image_640x480.jpg'. (Note thatthe single quotes are necessary in Unix shells due to the '$'symbol, but double quotes are required in a Windows cmd shell.)
4.exiftool -r -directory=%e_images/%d pics
Recursively move all images based in directory 'pics' toseparate directory trees organized by file extension. For instance, in thisexample the file 'pics/toys/new_car.jpg' is moved to'jpg_images/pics/toys/new_car.jpg'.
5.exiftool -r -o dummy/ -directory=%e_images/%d pics
Same as example 3 above, but images are rewritten instead of being moved sincethe -o option is used. Note that the trailing '/' on'dummy/' is necessary because 'dummy' alone could beinterpreted as a file name.
6.exiftool -r -d %Y/%m/%d/image_%H%M%S.%%e '-filename<filemodifydate' DIR
Recusively rename all images in 'DIR' and any containedsubdirectories to the form 'image_HHMMSS.EXT' (where'ext' is the original file extension), and move them into a newdirectory hierarchy based on date of file modification, with path names like'2006/03/27/image_105859.jpg'.

The following examples demonstrate the interaction of this feature withother ExifTool options:

7.exiftool -filename=new.jpg dir/image.jpg

Exiftool Geotagging Examples

Rename 'dir/image.jpg' to 'dir/new.jpg'.
8.exiftool -filename=new.jpg -comment=xxx dir/image.jpg
Copy 'dir/image.jpg', add a new comment, and write output to'dir/new.jpg'. The original file 'dir/image.jpg' isnot changed.
9.exiftool -filename=new.jpg -comment=xxx -overwrite_original dir/image.jpg
Rewrite 'dir/image.jpg', adding a new comment and writing output to'dir/new.jpg'. The original file 'dir/image.jpg' isremoved.
10.exiftool -o tmp/ -filename=new.jpg image.jpg
exiftool -o tmp/xxx.jpg -filename=new.jpg image.jpg
exiftool -o tmp/new.jpg image.jpg
A file name or directory specified via the FileName or Directorytag takes precedence over that specified by the -o option, so thesethree commands all have the same effect: 'tmp/new.jpg' is createdwithout changing 'image.jpg'. Note that in the first command, thetrailing '/' on 'tmp/' is necessary if the'tmp' directory doesn't already exist, otherwise 'tmp'would be taken as a file name and 'new.jpg' would be created in thecurrent directory. As illustrated in example 4 above, the file is rewritteninstead of simply being renamed when the '-o' option is used.
11.exiftool -directory=dir1 -filename=dir2/out.jpg -o dir3/ dir4/image.jpg
This example demonstrates the priorities of directory names specified usingdifferent techniques. The output directory is taken from the first directoryspecified from the following list: 1) the Directory tag, 2) theFileName tag, 3) the -o option, or 4) the original sourcefile, in that order. Note that both the FileName tag and the-o option may be used without a directory specification, in whichcase the directory with the next highest priority is used. So in this example,the output file is 'dir1/image.jpg'. The order of the arguments onthe command line is not significant.

Common Date Format Codes

Date format codes are used in the argument to the -d option torepresent components of the date/time string. The codes listed belowrepresent those which are common across most systems, but additional codeswill be available on your specific system -- see your strftime manpage for details.

%a- abbreviated locale weekday name
%A- full locale weekday name
%b- abbreviated locale month name
%B- full locale month name
%c- preferred locale date/time representation
%d- day of month (01-31)
%H- hour on a 24-hour clock (00-23)
%I- hour on a 12-hour clock (01-12)
%j- day of year (001-366)
%m- month number (01-12)
%M- minute (00-59)
%p- 'AM' or 'PM'
%S- seconds (00-59)
%w- weekday number (0-6)
%W- week number of the year (00-53)
%x- preferred locale date representation
%X- preferred locale time representation
%y- 2-digit year (00-99)
%Y- 4-digit year (ie. 2006)
%Z- time zone name
%%- a literal '%' character

Note that ExifTool file name format codes may be used inside a date formatstring when a date/time tag is used to set the value of the FileName orDirectory tags via the command-line interface. In this case, an extra'%' must be added to pass the format code through the date/timeparser:

Exiftool Examples English

%%d- original file directory
%%f- original file name
%%e- original file extension
%%c- copy number (output files only)

Exiftool Windows Examples

See the-w option in the exiftoolapplication documentation for details about special features available withthese name format codes.

Comments are closed.