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, here is a simple bash script, just save it for example as, run chmod +x, and then run sh This will make subfolders of jpg, png, txt, and so on, moving files with that extension in their corresponding folders.

echo "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 \;