How to find usable files among recovered files?
When you use a data recovery program like Recuva, it can "recover" lots of files which lots of them are just unusable with random data in them but somehow having correct filenames. Is there any way to automatically detect those files or files having meaningful data but needing repairs and delete the rest of the files which are junk?
Under linux, the utility file
might be worth looking into. It "tests" each file you pass to it using three different kind of tests instead of relying on the filename's extension. (See man file
for an explanation of the different tests).
Here's an approach for testing every file in a directory and copying it into a new folder if it's a JPEG image.
#!/bin/bash
mkdir useful
for cfile in *; do
fileres=$(file -b --mime-type "${cfile}")
if [[ "${fileres}" == "image/jpeg" ]]; then
cp "${cfile}" "useful/"
fi
done
Run this script in the directory with all your recovered files, and it will copy only jpeg files to the useful
directory. If you're looking for other filetypes simply replace the image/jpeg
in my script with the mime-type of the files you are interested in.