Integrity checks of different file types after hard disk crashes

So, your hard disk crashed?

You rescued it with ddrescue/other tools?

Now you don’t know if the files are still intact?

Here some solutions for some media file formats:

  • Movies (avi, mpeg, mp3, mkv, webm, … everything ffmpeg can decode.)
    • ffmpeg -v error -i "$1" -f null - 2>"$1".log
    • decodes a movie or audio file and reports all errors into a logfile, so if you do that for every of your files you get a bunch of logfiles which you can grep for Read errors, then you have an idea which movies are damaged.
    • #!/bin/bash                                 
      if [ ! -e "$1.log" ]; then                  
              echo "Checking file: $1"            
              ffmpeg -v error -i "$1" -f null - 2>"$1".log                                    
              ls -l "$1".log                      
              echo "$1 already checked."          

      find . -type f -size +1M -exec ./ "{}" \;

  • Pictures (png, jpg/jpeg)
    • Use pngcheck for pngs
    • Use jpeginfo -c for jpgs
  • Music (flac)
    • Just use flac -t to test a flac file

When I find some other useful integrity check methods for other file types or media I may add some.