# /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.
zenity --info --text "FUNDL - File Undeleter - by Nanni Bassetti and Denis Frati"
imm=`zenity --file-selection --title="Choose the image file or the device (eg. /media/disk.dd)"`
data=$( date | sed 's/ //g' | sed 's/://g')
outputdir="rec"$data
mkdir $outputdir
zenity --info --text  "If mmls cannot determine the partition type, try the partition starting sector 0 "
mmls $imm | zenity --text-info --width=700 --height=500 --title="These are the partitions/areas"
offs=`zenity --entry --title="FUNDL - File Undeleter - by Nanni Bassetti and Denis Frati" --text="Insert the partition starting sector (eg. 63):"`
fls -f list
fs=`zenity --entry --title="FUNDL - File Undeleter - by Nanni Bassetti and Denis Frati" --text="Insert the file system type (type fls -f, in a terminal window, list to see all fs supported): "`

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 | zenity --text-info --width=700 --height=500 --title="Recoverd files into the directory "$outputdir
exit 

