
How to Use the Command 'exiftool' (with Examples)
ExifTool is a powerful command-line application used to read, write, and edit metadata of files, especially images and videos. Metadata provides information about certain aspects of data, such as how and when it was created, any changes made to it, and so forth. People use ExifTool to manage and manipulate this data efficiently, making it a valuable tool for professional photographers, digital archivists, and technology enthusiasts.
Use Case 1: Print the EXIF Metadata for a Given File
Code:
exiftool path/to/file
Motivation: Understanding metadata is crucial for various reasons; it helps in organizing photos, tracking when and where they were taken, and much more. By printing the EXIF metadata for a given file, users can glean insights about the file that can help manage and categorize their image collections effectively.
Explanation:
exiftool
: The command itself, invoking the tool to perform actions related to metadata.path/to/file
: The target file for which you want to view the metadata. This needs to be replaced with the actual file path.
Example Output:
File Name : example.jpg
File Size : 3.5 MB
Date/Time : 2023:01:15 14:23:11
Camera Make : Canon
Camera Model : EOS 5D
...
Use Case 2: Remove All EXIF Metadata from Given Files
Code:
exiftool -All= path/to/file1 path/to/file2 ...
Motivation: Privacy and security are serious concerns when sharing images online. EXIF metadata might contain sensitive information like GPS coordinates. Removing all metadata ensures that no extraneous information is inadvertently shared.
Explanation:
-All=
: This argument is used to delete all metadata tags from the file.path/to/file1 path/to/file2 ...
: The files from which you want to remove metadata.
Example Output: Success messages indicate that metadata has been removed from specified files.
Use Case 3: Remove GPS EXIF Metadata from Given Image Files
Code:
exiftool "-gps*=" path/to/image1 path/to/image2 ...
Motivation: Sometimes you want to keep certain metadata while removing sensitive information like location data. This use case focuses on removing only the GPS data to maintain privacy while preserving other data.
Explanation:
"-gps*="
: This wildcard argument removes any metadata tag that begins with ‘gps’, effectively stripping GPS information.path/to/image1 path/to/image2 ...
: The images from which GPS data should be removed.
Example Output: Success confirmation for each image file indicating that GPS metadata has been removed.
Use Case 4: Remove All EXIF Metadata, Then Re-Add Metadata for Color and Orientation
Code:
exiftool -All= -tagsfromfile @ -colorspacetags -orientation path/to/image1 path/to/image2 ...
Motivation: Preserving essential image data such as color profiles and orientation while ensuring all other metadata is stripped away is useful for compatibility and display reasons across devices and platforms.
Explanation:
-All=
: Strips all metadata.-tagsfromfile @
: Means ‘copy tags from original’, where@
refers to the original file.-colorspacetags -orientation
: Re-adds these specific tags after removing all metadata initially.path/to/image1 path/to/image2 ...
: Targets the subject image files.
Example Output: Confirmation that all metadata was removed, and selective tags were re-added for specified files.
Use Case 5: Move the Date at which All Photos in a Directory Were Taken 1 Hour Forward
Code:
exiftool "-AllDates+=0:0:0 1:0:0" path/to/directory
Motivation: Adjusting timestamps can be necessary when daylight savings changes are not correctly reflected, or when sorting by date. Shifting all dates forward by one hour can correct the timeline of when images were captured.
Explanation:
"-AllDates+=0:0:0 1:0:0"
: Adjusts the ‘AllDates’ meta value by adding one hour.path/to/directory
: Refers to the directory containing the photos to be modified.
Example Output: Output confirms the success of the date change for each file in the directory.
Use Case 6: Move the Date at which All JPEG Photos in the Current Directory Were Taken 1 Day and 2 Hours Backward
Code:
exiftool "-AllDates-=0:0:1 2:0:0" -ext jpg
Motivation: Similarly to the previous use case, there might be instances requiring date-time adjustments. Here, you’re shifting date-time data backwards across JPEG files, helpful for correcting accidental forward future timestamps.
Explanation:
"-AllDates-=0:0:1 2:0:0"
: Substracts 1 day and 2 hours on the ‘AllDates’ metadata.-ext jpg
: Targets only JPEG files in the current directory.
Example Output: Confirmation of successful timestamp changes for each JPEG image.
Use Case 7: Only Change the DateTimeOriginal
Field Subtracting 1.5 Hours, Without Keeping Backups
Code:
exiftool -DateTimeOriginal-=1.5 -overwrite_original
Motivation:
Specifically targeting the DateTimeOriginal
field could be useful in scenarios such as correcting the time zone or when a camera’s clock was incorrectly set. The -overwrite_original
avoids creating duplicates or backups, conserving storage.
Explanation:
-DateTimeOriginal-=1.5
: Deducts 1.5 hours from the original date and time.-overwrite_original
: Prevents the creation of backup files, implementing direct file modification.
Example Output:
Success indication for each alteration of the DateTimeOriginal
field.
Use Case 8: Recursively Rename All JPEG Photos in a Directory Based on the DateTimeOriginal
Field
Code:
exiftool '-filename<DateTimeOriginal' -d %Y-%m-%d_%H-%M-%S%%lc.%%e path/to/directory -r -ext jpg
Motivation: Renaming files based on when they were originally taken provides a systematic, chronological way to organize images, making it easier for retrieval and archiving. This is especially useful after bulk imports of photos from different devices.
Explanation:
'-filename<DateTimeOriginal'
: Renames the file usingDateTimeOriginal
metadata.-d %Y-%m-%d_%H-%M-%S%%lc.%%e
: Formats the new file name using date and time while retaining the original case and extension.path/to/directory
: Specifies the target directory.-r
: Recursively applies the command through subdirectories.-ext jpg
: Only processes JPEG files.
Example Output: Files renamed to a structured format, confirming that filenames have been updated to reflect their original date-time values.
Conclusion:
ExifTool is an indispensable utility in the realm of digital photo management. Through illustrative examples, this article has demonstrated various contexts in which ExifTool can be applied, from basic metadata retrieval to complex batch processing. A proper grasp of ExifTool’s functions enables users to manage their digital content both efficiently and securely.