Open In App

Installing and Using Exiftool on Linux

Last Updated : 11 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

EXIF tool is a widely used meta-data information recorder built on Perl by Phil Harvey. It is one of a kind open-source tool which works on a variety of file types. EXIF stands for Exchangeable Image File Format, and it is mainly used for including metadata in various file types like txt, png, jpeg, pdf, HTML and many more. With EXIF tool we can also read, write and manipulate such meta-data information.

Installation:

Exiftool is an open-source tool. The library is built with Platform Independent Perl library. 

1. Clone the git repo onto your system.

git clone https://github.com/exiftool/exiftool.git

2. Test the tool with a test file present in the repository

cd exiftool
./exiftool t/images/ExifTool.jpg

Exiftool Installation

Alternatively, on Ubuntu distribution you can use:

sudo apt install libimage-exiftool-perl

Exiftool Installation

Or simply use the following command it will automatically capture the above command.

sudo apt install exiftool

Exiftool Installation

For downloading directly from the Source, use the following commands. This will work for any Linux distro including CentOS.

wget https://sourceforge.net/projects/exiftool/files/Image-ExifTool-12.16.tar.gz
tar xvf Image-ExifTool-12.16.tar.gz
cd Image-ExifTool-12.16/
./exiftool t/images/ExifTool.jpg

Exiftool InstallationExiftool Installation

To install it globally, make install the file.

Note: As it runs on Perl, you must have Perl installed on your Linux Distro.

perl Makefile.PL
make
make test
make install

Exiftool InstallationExiftool InstallationExiftool Installation

You can now run ExifTool anywhere in your terminal by typing exiftool.

Usage:

Reading Meta-Data:

1. To extract the entire list of metadata from the file uses the following command.

exiftool  <filename>

Exiftool  usage

2. To extract the ids along with the Exif Tags in their Hexadecimal Format, run the above command with -H flag.

exiftool -H <filename>

Exiftool  usage

3. ExifTool maintains the list of most common Exif Tags for a file, which could be viewed with the following flag.

exiftool --common <filename>

Exiftool  usage

4. With ExifTool we can also extract the preview image or the thumbnail of an image file.

exiftool -PreviewImage [filename.jpg] > [Output.jpg]
exiftool -ThumbnailImage [filename.jpg] > [Output.jpg]

Exiftool  usage

Example:

exiftool -b -PreviewImage CSM30803.CR2 > abc.jpg

-b to extract binary information and store the result in abc.jpg file

exiftool -b -ThumbnailImage CSM30803.CR2 > thumb.jpg

5. We can also generate extended information with verbose mode. This will display us the comprehensive data about the process that it is performing.

exiftool -v <filename>

Writing Meta-Data:

To edit any meta-data we can use it’s corresponding Exif Tag to make the changes.

Note: We can only change the tags that are not write-protected.

exiftool  -<Exif Tag>= “Geek Alert”  <filename>

Writing Meta-Data:

Removing Meta-Data:

If we want to erase all the existing information within the meta tags of the file, we can use the following command . This command will remove all the Meta-Data from the file leaving all the basic or protected tag information.

exiftool  -all=  <filename>

Removing Meta-Data

Saving Meta-Data:

We can save the output of the exiftool within another file (preferably a text file) to store the info for later use.

exiftool [filename] > [meta-data.txt]
cat <meta-data.txt>

Application:

1. Sorting Image Files into Folders by Year and Month

We can combine the information from the metadata to solve variety of tasks. Suppose we have a lot of Images and we want to sort them into new folders and arrange them by year, month, or days, then we can use the following command:

The command copies the old images into directories based on their year and month.

exiftool -o '-Directory<CreateDate' -d ./newimage/%y/%y%m -r ./oldimage
  • -o make copies of all the images (hereafter referred to as old images) and make new images out of them
  • -Directory<CreateDate moves the images to their new destination folders using the Image Creation Date
  • ./newimage/%y/%y%m is the relative path to the new directory, it follows the naming convention as year followed by subdirectory as year month.
  • -r is the recursively execute the command over the source folder
  • ./oldimages is the source folder where original images are stored

Example:

To make a change in the current directory, move the image to directories. 

exiftool '-Directory<CreateDate' -d %Y/%m-%d .

 We can see the images are moved into a new folder with the year and then month-day subfolders.

exiftool Application

2. Renaming Image Files According to their Creation Date

Suppose you are working for a photography firm and you clicked photos for many events but the photos got mixed and now manually segregating each image will require a lot of wasted effort. 

Here we will take advantage of the exiftool to segregate/ rename all the raw files present inside the current folder and it’s subfolder according to the exif tag of metadata Create Date and Time.

exiftool '-filename<CreateDate' -d %y%m%d-%H%M%S%%-03.c.%%e -r ./imagepath
  • -filename<CreateDate renames the raw images using image’s Creation Data & Time
  • -d sets the format for date/ time values
  • %y%m%d-%H%M%S%%-03.c.%%e is the format to rename the file.

For Example: This would rename a file taken on Feb 1, 2021, at 14:08 to 20210201-1408-000.xxx. The three zeros after the time are a copy number put there by %%-03.c in the date format. 

While renaming files, copy number keeps on incremented until it finds a filename that does not exist yet.

  • .%%e keeps the original file name extension
  • Use .%%le (for renaming extension in lowercase) or .%%ue (for renaming in uppercase)
  • -r is the recursively execute the command over the source folder
  • ./imagepath is the relative path to the directory with all your images to be renamed.

exiftool Application

Example:

To make a change in current directory.

exiftool -d %Y-%m-%d_%H.%M.%S%%-c.%%e "-filename<CreateDate" .

ExifTool is a very powerful tool for manipulating file metadata. It got wide-ranging applications and with all those flags and options possibilities are endless.



Similar Reads

Installing Java 14 in Ubuntu and Linux Mint
The JDK is a development environment for building applications using the Java programming language. The JDK includes tools useful for developing and testing programs. Here we will install the Java14 in Linux. Installing in Ubuntu: Here we are going to PPA repositories to install javajdk-14 on ubuntu/LinuxMint Operating Systems. PPA are managed by t
2 min read
Installing Viber in Linux 32 Bit And 64 Bit Systems
Viber is Free and secure calls and massager app for mobile and desktop. It can be used to make free phone calls, send text messages, photos, stickers, and video calls through the Voice Over Internet Protocol technology(VOIP). A Special thing about Viber is it is free of cost and no advertising. Viber can be used on almost all phones and desktop OS.
3 min read
Linux - Installing PIP to Manage Python Packages
Python is the most popular language for a decade, and we all know that python had a huge support of libraries that are used in different sectors of Software Engineering. Meanwhile, PIP also getting its fame along with python in Linux and developers community.PIP is a package manager for python in handling the software packages that are developed us
3 min read
Linux - Installing locate Command to Find Files
In this article, we will see how to install locate command to find files in Linux. locate is a command-line interface tool used for finding files by name in Linux systems. This works more efficiently than other commands. It uses one or more databases by updatedb. To check whether locate utility is already installed in your system. Open up your term
2 min read
Linux - Installing Tripwire IDS (Intrusion Detection System)
IDS(Intrusion detection system) is a software application that monitors your system and checks whether any malicious activity is found or not and reports that to the administrator. Security is a big issue for any Linux administrator, so today we are going to discuss how you can install Tripwire IDS on Linux, Tripwire is a popular open-source Linux
2 min read
Installing Open Source TV Streaming Server TvHeadend in Linux Mint
A server program that reads video streams from LinuxTV sources and publishes them as internet streams is TVHeadend, often TVH for short. For example, it supports multiple inputs, a DVB-T USB tuner stick and a Sat &gt; IP tuner, combining them into a single list of channels. TVH servers are IP signal providers themselves, allowing TVH server network
3 min read
Installing atop Tool To Monitor the System Process in Linux
atop is an ASCII full-screen interactive performance monitor which is kind of similar to the top command to view the load over a Linux system. The job of the most critical hardware resources (from a performance point of view) at the system level, i.e. CPU, memory, disk, and network can be seen. atop enable us to identify which processes are actuall
7 min read
Installing OpenVAS on Kali Linux
OpenVAS, an endpoint scanning application and web application used to identify and detect vulnerabilities. It is widely used by companies as part of their risk mitigation solutions to quickly identify gaps in their production and even development servers or applications. This is not a complete solution, but it can help you fix common security vulne
5 min read
Installing Kate text editor on Linux
In Linux, as there are various text editors like Vi and Vim, but all these editors are terminal-based, there is no responsive User Interface in these editors, so we can install UI-based text editors on Linux. There is one of the editors named Kate, which is a popular choice of many Linux users, as this editor is Open-software, it is free to use. Th
5 min read
The Ultimate Guide to Installing Blender on Linux Systems
Blender is one of the friendly tools that is used for making 3D things on computers. Artists and designers like to work with it a lot. This article will help you to install the software Blender on Kali Linux(for installing Kali Linux on your virtual box you can check here) or in Ubuntu very easily. You can get it from Blender’s website, or by using
4 min read