A friend of mine accidentally formatted her 2TB backup drive and brought it to me to see what I could do. PhotoRec was the only tool that would give more than a hint of recoverable data from my Linux-based laptop. After letting it run for several hours, I had a mess: PhotoRec recovered over 230,000 files, and spread them out over 430 directories!
Finding and sorting them by hand was obviously out of the question as it would take way too long. I took a hint from another recovery program I had [unsuccessfully] tried, and thought of sorting them into directories based on their file extensions. I.e. .jpg into ‘jpg’, .doc into ‘doc’, etc.
However, since I was working with the large number of files and directories, I had to take this a bit further. This will sort files into directory names like ‘jpg.1’, ‘jpg.2’, etc. These are numbered to prevent putting too many files in a single directory and killing system performance :)
I came up with the following bash script for use on Linux systems. A word of caution is due: This script does very little error checking, though the commands are quite sensible and I ran it as-is with fine results. I’m not responsible for unanticipated results.
UPDATE: This has moved to github, here.
Questions, comments, and feedback are welcome. Please leave them in the comments section below. Thank you!