#!/bin/bash DRY_RUN=1; if [[ "$1" == "delete" ]]; then DRY_RUN=0; else echo "Dry run. To delete broken PDFs, run with 'delete' as the first argument."; fi for f in $(cat broken_pdfs.txt); do files="$(find . -name "$f" -print)"; if [[ "$files" == "" ]]; then continue; fi for file in "$files"; do if [[ $DRY_RUN != 0 ]]; then echo "Would delete $file"; else echo "Deleting $file"; rm "$file"; fi done done