Hello, friends. In this post, I will show you How to get and change PDF metadata on Linux using the terminal. So, you can quickly use it for a specific case or several files. You can even include it in scripts.
Is this really useful?
The reality is yes. Many times in configuration scripts we can include various commands to automate processes, and file management is no exception.
Besides this, it is always useful to have the terminal at hand, since it is faster and more efficient than in a graphical interface. Moreover, this will ensure that it will work in almost any environment.
So, let’s get started.
Install necessary packages
To perform the task, we need a tool called exiftool with which we can edit the metadata of a PDF file without major problems.
sudo apt install libimage-exiftool-perl
sudo dnf install perl-Image-ExifTool
For Arch Linux based distirbutions
sudo pacman -S perl-image-exiftool
Once you have the package installed, you can continue with the post.
Getting and changing PDF metadata on Linux using the terminal
If you want to get the metadata of any PDF file, you can run
Of course, you can use relative and absolute paths to get the results.
Note: For this post i used an sample PDF file from here
If you would like to get only an extract of this metadata, you can do it as follows
exiftool -Creator sample.pdf
This means that the output screen will only show the author of the document.
Creator : Rave (http://www.nevrona.com/rave)
It can also be other metadata
exiftool -Keywords sample.pdf
In case you want to change some metadata, say the Creator.
exiftool -Creator="Unixcop" sample.pdf
Also if a metadata is not specified, you can add it with the above syntax. For example, I will add Author.
exiftool -Author="Unixcop" sample.pdf
So the syntax is simple, just define the metadata and specify the new value.
If you want to simply remove a metadata, then leave it blank
exiftool -Author= document.pdf
It’s that simple.
But it is possible to clear them all
exiftool -all= document.pdf
Then all metadata will be blank.
In this post, you learned an important part of manipulating PDF files. I hope you liked it.