-
-
Save JavierAroche/cf6fc557f0be697a1f3238abaa88b2e4 to your computer and use it in GitHub Desktop.
Find corrupted files using GM identify
This file contains hidden or 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
folderToCheck='/Volumes/16TB/whatever/path' | |
outputFile=~/Desktop/files.txt | |
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 "OK $line" >> $outputFile | |
status=${Green} | |
else | |
echo "ERROR $line" >> $outputFile | |
status=${Red} | |
fi | |
echo "${status}File ${counter} of ${count}${Color_Off} → ${line##*/}" | |
counter=$(( $counter + 1 )) | |
done | |
echo "Wrote file ${outputFile}" | |
echo "-------------- DONE --------------" |
Uhmm... actually it passes a psb file that is corrupted... I will investigate and report back!
UPDATE
It turns out that a PSB which has corrupted layers, but an OK composite image will pass the identify
test without the -verbose
flag (that's the reason why your original code was ultra-fast compared to mine). I've added -verbose
, and apparently it works, even if I don't know enough shell scripting to understand why it is able to discern whether "$result"
is an OK message or an Error :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Javier!
I had to wrap in quotes the
${folderToCheck)
in line 9 (i.e.cd "${folderToCheck}"
), because otherwise a path with white spaces would break thecd
command. The file extensions, too, must be wrapped in quotes ("*.psd"
). I also had to add-e
flag toecho
, see my updated gist here – I don't know if I can issue a pull request for gists :-) Thanks again!!