25

the title says it all. is there a tool?

I installed ExifTool, but can't find a way to remove all at once with one command.

aaaa
  • 1,233
  • 3
  • 13
  • 13
  • Related: https://askubuntu.com/questions/260810/how-can-i-read-and-remove-meta-exif-data-from-my-photos-using-the-command-line – Jesse Nickles Mar 08 '23 at 19:16

6 Answers6

27
exiftool -all= inputfile

The latest version of exiftool supports most file formats.

Output:

  1. If the input file contained metadata, it removes the metadata and overwrites inputfile, but saves a copy of the original as inputfile_original in the same folder.
  2. If the input file did not contain metadata, it performs no changes.

There are options in ExifTool to delete the original file: -overwrite_original and -overwrite_original_in_place.

jarno
  • 5,600
10

The Metadata anonymisation toolkit would do the trick for you. It has a GUI as well.

After Enabling the Universe Repository you can install it with:

sudo apt-get install mat
  • Doesn't support PDF files. – Foreever Apr 29 '19 at 08:20
  • 1
    currently apt install mat actually installs the mat2 command. Here's its canonical repository. It's easy to use, just mat2 foo.jpg. – 300D7309EF17 Feb 07 '21 at 18:40
  • @Foreever it supports PDF files but compared to the combination of exiftool / qpdf, it does the PDF export as an image, which is less nice / accessible than a PDF that contains text that you can copy-paste. Maybe they do this on purpose so people cannot guess the date / software version used based on the PDF structure. – baptx Apr 14 '21 at 10:31
  • I asked the author of mat2, he said it is possible to use text instead of images with the lightweight mode (-L option: https://0xacab.org/jvoisin/mat2#notes-about-the-lightweight-mode) but it will not clean metadata of embedded resources like images (https://0xacab.org/jvoisin/mat2/-/blob/master/doc/implementation_notes.md#lightweight-cleaning-mode). – baptx Apr 22 '21 at 10:06
7

Yes, there is a tool to remove metadata called exiv2.

Usage: exiv2 rm /path/to/location/files

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Raja G
  • 102,391
  • 106
  • 255
  • 328
6

When using the command exiftool -all= inputfile shared here on PDF files, I got this message:

Warning: [minor] ExifTool PDF edits are reversible. Deleted tags may be recovered!

And by looking for the error message on a search engine, I found https://exiftool.org/forum/index.php?topic=4722.0 with a link to https://exiftool.org/TagNames/PDF.html that mentions:

All metadata edits are reversible. While this would normally be considered an advantage, it is a potential security problem because old information is never actually deleted from the file. (However, after running ExifTool the old information may be removed permanently using the "qpdf" utility with this command: "qpdf --linearize in.pdf out.pdf".)

So if you really want to delete the metadata from PDF files so it cannot be recovered instead of just hiding it, you should use the command qpdf --linearize in.pdf out.pdf afterwards.

If you want to try to recover the hidden / removed metadata from PDF files, the man page https://exiftool.org/exiftool_pod.html explains how to do it:

Changes to PDF files by ExifTool are reversible (by deleting the update with -PDF-update:all=) because the original information is never actually deleted from the file. So ExifTool alone may not be used to securely edit metadata in PDF files.

So the command will be something like exiftool -PDF-update:all= inputfile. You can then check the properties of the file in your PDF viewer to see if the metadata is restored.

Note: this solution does not clean metadata of embedded resources like images unlike the tool mat2 shared in another answer (except when using lightweight mode: https://0xacab.org/jvoisin/mat2/-/blob/master/doc/implementation_notes.md#lightweight-cleaning-mode). But images metadata is not always present in PDF files. For example to do a PDF export with LibreOffice Writer and keep metadata, we need to disable "Reduce image resolution" (an answer also mentioned that we need to enable "Lossless compression" but I did not need it: https://security.stackexchange.com/questions/185507/does-embedding-images-in-pdf-retain-metadata). Then I was able to save the image with metadata from the PDF file with LibreOffice Draw and view the metadata with GIMP in the menu "Image -> Metadata -> View Metadata".

baptx
  • 477
4

You can use Metadata Extraction Tool

The Metadata Extract Tool includes a number of 'adapters' that extract metadata from specific file types. Extractors are currently provided for:

  • Images: BMP, GIF, JPEG and TIFF.
  • Office documents: MS Word (version 2, 6), Word Perfect, Open Office (version 1), MS Works, MS Excel, MS PowerPoint, and PDF.
  • Audio and Video: WAV, MP3 (normal and with ID3Tags), BFW, FLAC.
  • Markup languages: HTML and XML.
  • Internet files: ARC

If a file type is unknown the tool applies a generic adapter, which extracts data that the host system 'knows' about any given file (such as size, file name, and date created).

For more information, and to download visit Metadata Extraction Tool

Source:Metadata Extraction Tool

Mitch
  • 107,631
4

First, install exiftool using this command:

sudo apt-get install libimage-exiftool-perl

Then, go into the directory with the JPEG files. If you want to remove metadata from every file in the directory, use

exiftool -all= *.jpg

For single file, use

exiftool -all= <filename>.jpg
Hassaan
  • 241
  • This doesn't work for mp3 files – baxx Jan 11 '19 at 17:43
  • @baxx OP does not mentioned to use this with .mp3 files – Hassaan Jan 11 '19 at 17:47
  • 2
    mp3 is a common file type that uses meta data and it's likely that someone will find this post as a result of searching ( I did ) – baxx Jan 11 '19 at 17:52
  • Be careful, like the other answer, this only hides data and does not delete it: https://askubuntu.com/questions/308250/is-there-a-tool-for-removing-metadata/1331315#1331315 – baptx Apr 14 '21 at 10:08