Terminal Command Line to find corrupted files

command lineiphotophotosterminal

I do have just one corrupted photo into my Photos Library.

Is there is any UNIX command line that I can use in terminal in order to scan my Photos Library Folder and find out which file is corrupted?

Best Answer

My first thought was that ImageMagick is bound to have something for this, and indeed it does. You could run something like this

find . -name "*.JPG" -exec identify {} \; | grep Corrupt

where you can replace . with your directory of choice (it will descend recursively) to check each file or image with ImageMagick's identify command. Grepping for 'Corrupt' will print you identifys output for those files which are in fact corrupt. You could probably trim the output to make it more readable, which would involve some regexing for grep.

Obviously, you need to have ImageMagick installed for this. If you use MacPorts, it's as simple as sudo port install ImageMagick.