Skip to content

Instantly share code, notes, and snippets.

@undavide
Forked from JavierAroche/find-corrupted-files.sh
Last active May 8, 2018 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save undavide/ecc5c60c747b5bc36380a1c5e9cd192f to your computer and use it in GitHub Desktop.
Save undavide/ecc5c60c747b5bc36380a1c5e9cd192f to your computer and use it in GitHub Desktop.
Find corrupted files using GM identify
folderToCheck='/Volumes/16TB/whatever/path'
outputFile=~/Desktop/FileIntegrity.log
counter=1
Red="\033[0;31m" # Red
Green="\033[0;32m" # Green
Color_Off="\033[0m" # Text Reset
cd "${folderToCheck}"
# Find all files and get count
count=$(find "$(pwd)" -type f -iname "*.psd" -o -iname "*.psb" | wc -l | xargs) # Optional count
# Find all files and iterate through all
find "$(pwd)" -type f -iname "*.psd" -o -iname "*.psb" | while read -r line ; do
result=$(identify "${line}")
if [ "$result" ] ; then
echo -e "OK $line" >> $outputFile
status="${Green}"
else
echo -e "ERROR $line" >> $outputFile
status="${Red}"
fi
echo -e "${status} File ${counter} of ${count}${Color_Off} → ${line##*/}"
counter=$(( $counter + 1 ))
done
echo "Wrote file ${outputFile}"
echo "-------------- DONE --------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment