Skip to content

Instantly share code, notes, and snippets.

@gmsotavio
Last active October 28, 2023 21:12
Show Gist options
  • Save gmsotavio/4bd63430ac71ad598554ff21330ef3e4 to your computer and use it in GitHub Desktop.
Save gmsotavio/4bd63430ac71ad598554ff21330ef3e4 to your computer and use it in GitHub Desktop.
List corrupted pdf files in a directory
#!/bin/bash
# Navigate to the folder containing your PDF files
cd /path/to/pdfs
# Create an empty text file to store the list of corrupted PDFs
corrupted_pdfs="corrupted_pdfs.txt"
> "$corrupted_pdfs"
# Loop through all PDF files and check for corruption
for pdf in *.pdf; do
pdftotext "$pdf" /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$pdf" >> "$corrupted_pdfs"
fi
done
# Display the list of corrupted PDFs
cat "$corrupted_pdfs"
@gmsotavio
Copy link
Author

sudo apt-get install poppler-utils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment