0

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?

  • 2
    Not exactly a duplicate, but may be useful: superuser.com/q/432535/432690 . – Kamil Maciorowski Jul 20 '18 at 19:38
  • @confetti I was looking for a way to do it in Windows as I'm not too much familiar with Linux unfortunately. But I marked it and thank you. – PsychoMotel Aug 1 '18 at 8:31
  • @confetti There's a Windows program called TrID File Identifier and it works great and also has a command line feature. Do you think we can write a simple program to automate checking every files in a directory by TrID? Here's the link to the program. – PsychoMotel Aug 1 '18 at 8:33
  • I found gnuwin32.sourceforge.net/packages/file.htm this, which claims to be "File for windows". Maybe that is a help. TrID looks great for the job, but I can't find a way to output only the extension or mime-type. Another idea would be to use a live linux distribution on an USB stick. It's really quick, doesn't change anything on your system (runs from USB) and after you ran my script you can switch back to windows. – confetti Aug 1 '18 at 14:37
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.