Find and Move Corrupted PDF Files

The accepted answer for that question seems good to me, just use the right syntax to move corrupted files:

for f in *.pdf; do
  if ! pdfinfo "$f" &> /dev/null; then
    mv /current/location/"$f" /new/location
  fi
done

Remember that you can help by executing mv --help as well as with man mv. If you want to change name of files, you can use the rename command.

3 Likes