# /bin/bash/
# FUNDL - File Undeleter
# Undelete tool by Nanni Bassetti - digitfor@gmail.com - http://www.nannibassetti.com - http://www.cfitaly.net
#  Denis Frati - http://www.denisfrati.it.
echo "FUNDL - File Undeleter - by Nanni Bassetti & Denis Frati"
echo "Insert the image file or the device: "
read imm 
data=$( date | sed 's/ //g' | sed 's/://g')
outputdir="rec"$data
mkdir $outputdir
#########################
mmls $imm
echo "If mmls can't determine the partition type, try the partition starting sector 0"
echo "Insert the partition starting sector (eg. 63):"
read offs
echo "Insert the file system type:"
fls -f list
read fs
fls -d -r -p -f $fs -o $offs $imm >$outputdir/filelist.txt
for i in  $(grep "r/r" $outputdir/filelist.txt|sed 's/[[:space:]]//g'|sed 's/r\/r//')  
# inode:nomedire/filename
do
inode=$(echo $i | awk -F ":" '{print $1}'|sed 's/*//')
#echo $inode
name="$(echo $i | awk -F ":" '{print $2}'| sed 's/\//SLASH/g')"
icat -f $fs -o $offs -r $imm $inode > $outputdir/$name 2>/dev/null
done
cd $outputdir
ls -ag
exit 
