Linux – Check if PDF files are corrupted using command line on Linux


I have many PDF files on one folder.

Is it possible check if one or more files are corrupted (zero pages, or unfinished downloads) using the command line, without needing to open them one by one?

Best Answer

You can try doing it with pdfinfo (here on Fedora in the poppler-utils package). pdfinfo gets information about the PDF file from its dictionary, so if it finds it the file should be ok

for f in *.pdf; do
  if ! pdfinfo "$f" &> /dev/null; then
    echo "$f" is broken