Need to find & convert thousands of multi-page TIFFs

homebrewpdfpreview

I have a large collection of documents in various formats (PDF, TIFF, JPEG).

Many of the TIFFs are multi-page, like faxes, and the only way I know to see all the pages is with Preview.

Is there some method or app or shell command (via brew) which can find all the multi-page TIFFs so that I can convert them to multi-page PDFs?

Best Answer

There is a way to find them using a command line in the terminal. This requires you to install a tool which is not part of the default command set.

Download and install exiftool.

exiftool is able to print detailed information about image files, including TIFFs. It can tell the difference between multi-page documents and between FAXes and photographic TIFFs. For example testphoto.tif is a regular TIFF file and testfax.tif is a multi-page FAX:

MacBook-Air:Downloads jamie$ exiftool -s -Format -Compression -SubfileType *.tif 
======== testfax.tif
Compression                     : T6/Group 4 Fax
SubfileType                     : Single page of multi-page image
======== testphoto.tif
Format                          : image/tiff
Compression                     : LZW
SubfileType                     : Full-resolution Image
    2 image files read

If we can get the filename and the identifying info on one line, then we can use grep to identify the files we want. The -csv option puts the output on one line in comma seperated value format. So, a command like this would do what you want.

MacBook-Air:Downloads jamie$ exiftool -csv  -SubfileType *.tif | grep multi-page
    2 image files read
testfax.tif,Single page of multi-page image

So, we have correctly identified testfax.tif as the only multi-page TIFF in this directory.