Skip to content

Instantly share code, notes, and snippets.

@Kegn
Last active October 8, 2019 15:43
Show Gist options
  • Save Kegn/9fc34ae145d1c78e35207ca71c121bf9 to your computer and use it in GitHub Desktop.
Save Kegn/9fc34ae145d1c78e35207ca71c121bf9 to your computer and use it in GitHub Desktop.

Revisions

  1. Kegn revised this gist Oct 8, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion photorec-filer.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    # shitty way but works kind of
    # for some reason it opies them all into the first directory, so
    # 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
  2. Kegn revised this gist Oct 8, 2019. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions photorec-filer.sh
    Original file line number Diff line number Diff line change
    @@ -13,11 +13,10 @@
    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 the item
    # for each item in the list, call the copyfile() function on the item
    for item in $list; do
    echo $item;
    copyfile $item;

    copyfile $item;
    done
    }

    @@ -26,9 +25,9 @@ copylist() {
    copyfile() {
    # make directory of recdata/filetype
    mkdir -p recdata/$1
    # file all instances of type with relative path
    # 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 filetyp
    # 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
    }

  3. Kegn created this gist Oct 8, 2019.
    36 changes: 36 additions & 0 deletions photorec-filer.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/bin/bash

    # shitty way but works kind of
    # for some reason it opies 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 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
    # file 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 filetyp
    while IFS='' read -r line || [[ -n "$line" ]]; do cp $line recdata/$1/ ; done < $1-file
    }

    # run copylist
    copylist