diff --git a/README.md b/README.md index d0db4bf..d93142b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ -# photosort +# PhotoSort +Bash script for sorting [PhotoRec](https://github.com/cgsecurity/testdisk) recovered data, but can be used for sorting any data by extension. -Bash Script to sort files into directories based on extension. \ No newline at end of file +[PhotoRec](https://github.com/cgsecurity/testdisk) sorts data in many directories, with no organization by filetype. This script creates a new directory with subdirectories for every filetype recovered by [PhotoRec](https://github.com/cgsecurity/testdisk), then moves files into their corresponding place. diff --git a/photosort.sh b/photosort.sh new file mode 100644 index 0000000..865adf6 --- /dev/null +++ b/photosort.sh @@ -0,0 +1,14 @@ +#!/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