Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We're recoverying bunches of data from a crashed partition of which we had no backup, using a data recovery software. Files are getting recovered, but file names are lost.

Is there any software or method we could use to automatically scan the file headers to try to determine its type (between the most common ones: image types, different kind of source code text files, compressed files, etc) and automatically put an extension on its random name, to help then processing the data?

Maybe this PHP function will help?

Thanks in advance.

share|improve this question
What OS are you using? Linux has the 'file' command which will identify the file type from the contents. You'd need to wrap a script around it to make it automagic, but that's not a big task... See for man page. – BobT Jan 7 '13 at 17:14
in addition to file, as @BobT said, you can also, on unix, read the original filenames (including their eventual extension, if any) from the (recovered) directory entries. The tricky part being to match file entry in a directory with a recovered file under another name... – Olivier Dulac Jan 7 '13 at 17:20
@BobT we don't depend on a particular OS to do this task, we can adapt. Your suggestion seems useful. – Áxel Costas Pena Jan 7 '13 at 17:39
@OlivierDulac, directory entries are unrecoverable, data recovery software is giving random names to files. Thanks anyway ;) – Áxel Costas Pena Jan 7 '13 at 17:40
Maybe you can recover the dir themselves (ie, the inode who contained a dir entry. That inode will, in turn, contain the former list of files+dirs "directly underneath it", and can be read by several means). The soft maybe rename those directories names too, but their content should still contain the former lists. – Olivier Dulac Jan 7 '13 at 23:32

You can use TrID for that. There are versions for both Windows and Linux. It can scan multiple files and with the "-ae" switch it can rename each one adding the guessed extension.

Disclaimer: I'm TrID's developer.

share|improve this answer
thanks @Mark0, such an interesting project! Am I missing a -r recursive parameter for asterisk-dot-asterisk mask? – Áxel Costas Pena Jan 9 '13 at 9:27
Thanks @Áxel. Indeed, no directories recursion at the moment; it's coming in a next versions. – Mark0 Jan 9 '13 at 13:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .