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.

PhotoSort

git clone https://github.com/signal-9/PhotoSort.git && cd PhotoSort && chmod +x photosort.sh

Then just run it:

sh photosort.sh

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:

#!/bin/bash
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)
do
mkdir $destinationfolder/$extensions
find $sourcefolder -name \*.$extensions -exec mv {} $destinationfolder/$extensions \;
done