Last active
October 8, 2019 15:43
-
-
Save Kegn/9fc34ae145d1c78e35207ca71c121bf9 to your computer and use it in GitHub Desktop.
Sorts files from photorec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # shitty way but works kind of | |
| # for some reason it copies them all into the first directory, so | |
| # copy the functions into a terminal then run manually | |
| # makes a list of filetypes from photorec recovery | |
| # then makes a list of files | |
| # then makes directories for each one | |
| # then it copies the files into the appropriate folder | |
| # start in folder with all the recup*/ | |
| # 2019 kegn | |
| copylist() { | |
| # makes a list | |
| list=$(ls recup**/ | grep '\.' | cut -d. -f2 | sort -u | grep -v :) | |
| # for each item in the list, call the copyfile() function on the item | |
| for item in $list; do | |
| echo $item; | |
| copyfile $item; | |
| done | |
| } | |
| # takes filetype as arguement | |
| copyfile() { | |
| # make directory of recdata/filetype | |
| mkdir -p recdata/$1 | |
| # find all instances of type with relative path | |
| find . -name '*\.'$1 >> $1-file | |
| # while reading line from filetype-file, each line has a file. copy that file to the directory of filetype | |
| while IFS='' read -r line || [[ -n "$line" ]]; do cp $line recdata/$1/ ; done < $1-file | |
| } | |
| # run copylist | |
| copylist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment