PhotoRec is a great tool for recovering data, but it isn’t a great tool for sorting data. After using PhotoRec, you end up with sometimes hundreds or thousands of folders named ‘recup_dir.X’, with anything from text documents to custom files being randomly placed within them. On their site, they offer some ways to sort this data, but none of those methods worked well for me, so I made a simple little script that takes care of this.


git clone && cd PhotoSort && chmod +x

Then just run it:


This will search the recovered data, make subfolders of jpg, png, txt, and so on for each filetype found, and move files with that extension in their corresponding folders.

For reference, here is also the script if you want to manually save it:

echo "PhotoRec Recovered Data - Source Folder?"
# Example - /home/user/rootfolderofphotorecdata
read sourcefolder
echo "Destination Folder?"
# Example - /home/user/rootfolderofphotorecdata/SORTED (will be made if doesn't exist)
read destinationfolder
cd $sourcefolder
mkdir $destinationfolder
for extensions in $(find . -type f -name '*.*' | sed 's|.*\.||' | sort -u)
mkdir $destinationfolder/$extensions
find $sourcefolder -name \*.$extensions -exec mv {} $destinationfolder/$extensions \;