Pure Daft

PhotoRec geniuses

05 May 2009

I guess I deleted several of my photos (I blame my computer in part), but was able to restore (probably) all of them using photorec.

As there were many to recover, I also used a script to tidy up the results:

trash=trash$$
unknown=unknown$$
mkdir $trash
mkdir $unknown
for file in f*.jpg; do
newname=`exiv2 -p s $file | grep -a timestamp | awk '{ print $4 "-" $5 }' | sed 's/:/-/g'`
if [ $? -eq 0 -a "x$newname" != "x" ]; then
if [ ! -f ${newname}.jpg ]; then
mv $file ${newname}.jpg
else
cmp $file ${newname}.jpg
if [ $? -eq 0 ]; then
echo "WARN: $file is a duplicate of ${newname}.jpg: moved to $trash"
mv $file $trash
else
echo "ERR: ${newname}.jpg already exists but differs. $file unchanged"
fi
fi
else
echo "ERR: unable to get info from ${file}: moved to $unknown"
mv $file $unknown
fi
done

From http://icwww.epfl.ch/~chappeli/perso/recup_photos.html via http://sid.rstack.org/index.php/Digital_photos_recovery#Advanced_solution_for_tricky_situations.