How to use the command exiftool (with examples)

How to use the command exiftool (with examples)

Exiftool is a command-line tool that allows you to read and write metadata information in files, specifically EXIF metadata. This metadata includes information such as the date the photo was taken, camera settings, GPS coordinates, and much more. It provides a wide range of options to manipulate and modify the metadata in various ways.

Use Case 1: Print the EXIF metadata for a given file

Code:

exiftool path/to/file

Motivation: When working with images, it can be helpful to access and view the metadata information associated with a file. This information provides valuable insights into the photo, such as the camera model, aperture, shutter speed, ISO, and more. Print the EXIF metadata for a given file allows you to quickly access this data.

Explanation: The command exiftool path/to/file is used to print the EXIF metadata for a specific file. The path/to/file is the path to the file you want to extract metadata from. Exiftool will display all the available metadata for the given file.

Example Output:

ExifTool Version Number         : 12.25
File Name                       : example.jpg
...

Use Case 2: Remove all EXIF metadata from the given files

Code:

exiftool -All= path/to/file1 path/to/file2 ...

Motivation: Sometimes you may want to remove all EXIF metadata from image files. This can be useful if you want to strip sensitive or unnecessary information from the files, reduce file size, or prevent personal data from being shared when sharing images online.

Explanation: The command exiftool -All= is used to remove all EXIF metadata from the given files. The path/to/file1 path/to/file2 ... represents the path to the files you want to remove the metadata from. Exiftool will remove all the metadata tags from the specified files.

Example Output:

   1 directories scanned
  10 image files updated

Use Case 3: Remove GPS EXIF metadata from given image files

Code:

exiftool "-gps*=" path/to/image1 path/to/image2 ...

Motivation: Many modern cameras embed GPS coordinates in the EXIF metadata of the images they capture. If you want to remove the GPS information from your images, this command allows you to remove the GPS EXIF metadata specifically, keeping the rest of the metadata intact.

Explanation: The command exiftool "-gps*=" is used to remove the GPS EXIF metadata from the given image files. The path/to/image1 path/to/image2 ... represents the path to the image files you want to remove the GPS metadata from. Exiftool will remove all the GPS-related metadata tags, such as Latitude, Longitude, and Altitude, from the specified files.

Example Output:

    2 directories scanned
   10 image files updated

Use Case 4: Remove all EXIF metadata from the given image files, then re-add metadata for color and orientation

Code:

exiftool -All= -tagsfromfile @ -colorspacetags -orientation path/to/image1 path/to/image2 ...

Motivation: If you want to remove all the EXIF metadata from your image files and then add specific metadata tags back, such as color space and orientation, this command provides a way to achieve that.

Explanation: The command exiftool -All= -tagsfromfile @ -colorspacetags -orientation is used to remove all EXIF metadata from the given image files and then adds back metadata specifically for color space and orientation. The path/to/image1 path/to/image2 ... represents the path to the image files you want to modify. Exiftool first removes all the metadata tags (-All=), then copies the color space and orientation information from the original file (-tagsfromfile @), and finally adds the color space and orientation tags back to the image files.

Example Output:

    2 directories scanned
   10 image files updated

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: There are situations where you might want to adjust the date and time metadata of your photos. Moving the date at which all photos in a directory were taken forward or backward can help correct any discrepancies or adjust for time zone differences.

Explanation: The command exiftool "-AllDates+=0:0:0 1:0:0" is used to move the date at which all photos in a directory were taken forward by 1 hour. The path/to/directory represents the path to the directory containing the photos you want to modify. Exiftool will update the date and time metadata tags for all the files in the directory, adding 1 hour to the existing values.

Example Output:

    4 directories scanned
   21 image files updated

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: When working with a large number of photos, making adjustments to the date and time metadata can be tedious if done manually. This command allows you to automate the process and quickly modify the metadata for a specific file format (JPEG in this case) in the current directory.

Explanation: The command exiftool "-AllDates-=0:0:1 2:0:0" -ext jpg is used to move the date at which all JPEG photos in the current directory were taken 1 day and 2 hours backward. The -ext jpg option specifies that only files with the extension “jpg” should be considered. Exiftool will update the date and time metadata tags for all the JPEG files in the current directory, subtracting 1 day and 2 hours from the existing values.

Example Output:

    1 directories scanned
   10 image files updated

Use Case 7: Only change the DateTimeOriginal field subtracting 1.5 hours, without keeping backups

Code:

exiftool -DateTimeOriginal-=1.5 -overwrite_original

Motivation: In some cases, you may only want to modify a specific metadata tag without altering other metadata information or creating backups of the original files. This command allows you to change the DateTimeOriginal field while discarding backups.

Explanation: The command exiftool -DateTimeOriginal-=1.5 -overwrite_original is used to only change the DateTimeOriginal field subtracting 1.5 hours without keeping backups. Exiftool will modify the DateTimeOriginal metadata tag by subtracting 1.5 hours from its value for all the files in the current directory. The -overwrite_original option ensures that the original files are directly modified without creating any backups.

Example Output:

    1 directories scanned
   10 image files updated

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: When organizing a large collection of photos, it can be helpful to rename the files based on specific metadata tags. This command allows you to rename all the JPEG photos in a directory using the DateTimeOriginal field, resulting in a more organized file structure.

Explanation: The command exiftool '-filename<DateTimeOriginal' -d %Y-%m-%d_%H-%M-%S%%lc.%%e path/to/directory -r -ext jpg is used to recursively rename all JPEG photos in a directory based on the DateTimeOriginal field. The -d %Y-%m-%d_%H-%M-%S%%lc.%%e option specifies the desired filename format, which includes the date and time information. The %lc modifier is used to convert the extension to lowercase. The -r option enables recursion into subdirectories, and the -ext jpg option specifies that only files with the extension “jpg” should be renamed. Exiftool will rename all the JPEG files in the directory and its subdirectories based on their DateTimeOriginal value.

Example Output:

    5 directories scanned
   30 image files updated

Conclusion:

Exiftool is a powerful command-line tool that allows you to manipulate and modify metadata information in files. It provides a wide range of options to read, write, remove, and modify metadata tags in various ways. Whether you want to extract metadata, remove sensitive information, adjust the date and time metadata, or rename files based on metadata, Exiftool offers the flexibility and functionality needed to accomplish these tasks efficiently.

Related Posts

How to use the command `git root` (with examples)

How to use the command `git root` (with examples)

This article will provide step-by-step instructions on how to use the git root command with examples for different use cases.

Read More
How to use the command gitwatch (with examples)

How to use the command gitwatch (with examples)

Gitwatch is a command that allows you to automatically commit file or directory changes to a git repository.

Read More
How to use the command wasm2wat (with examples)

How to use the command wasm2wat (with examples)

WASM2WAT is a command that allows users to convert a WebAssembly binary file into a human-readable text format.

Read More