Last active
October 28, 2023 21:12
-
-
Save gmsotavio/4bd63430ac71ad598554ff21330ef3e4 to your computer and use it in GitHub Desktop.
List corrupted pdf files in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo apt-get install poppler-utils