script to process photorec data

Using PhotoRec to recover lost data
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read https://www.cgsecurity.org/testdisk.pdf
Locked
Message
Author
kikker
Posts: 2
Joined: 11 Jan 2013, 17:54

script to process photorec data

#1 Post by kikker »

Hi, since I didn't see it before, here's a small script to move photorec output files into correct dirs.
Similar to what it is http://www.cgsecurity.org/wiki/After_Using_PhotoRec, but simpler IMO.
Save it to "photorec_sortfiles.sh" it to the folder with your recup[..] dirs, make it executable "chmod +x photorec_sortfiles.sh" and launch as "./photorec_sortfiles.sh".

- If you don't have dash (most gnu/linux distros do) change dash for bash, it will do the same but slightly slower.
- If you want to copy instead of move, change 'mv ' for 'cp'

Code: Select all

#!/bin/dash

target=sorted_output
if [ -e $target ]; then echo "$target exists. exit."; exit; fi
mkdir $target 
for d in recup_dir.*/*; do
  ext=${f##*.}; 
  mkdir -p $target/$ext
  mv -nv $f $target/$ext/
done

echo "done. the following files could not moved (check permissions or double file names):"
ls recup_dir.*/*

Locked