Skip to content

Instantly share code, notes, and snippets.

@martinhynar
Last active December 30, 2015 22:58
Show Gist options
  • Save martinhynar/7897474 to your computer and use it in GitHub Desktop.
Save martinhynar/7897474 to your computer and use it in GitHub Desktop.
For those lucky ones that have screwed their hard drives and recovered gigabytes of randomly named photos with PhotoRec. This script takes input folder and output folder and moves all files that have EXIF tag File Source with value Digital Camera. This serves as first step on a long journey of walking through and watching all the recovered image…
#!/bin/bash
if [ ! -d $1 ]; then
echo $1 " must be directory"
exit
fi
if [ ! -d $2 ]; then
echo $2 " must be directory"
exit
fi
if [ $1 = $2 ]; then
echo $1 " must be different from " $2
exit;
fi;
source=$1
target=$2
for file in `ls $source | grep jpg`
do
fsource=`exiftool -FileSource $source/$file`
fsource=`echo $fsource | gawk --field-separator ':' '{print $2}' | tr -d ' '`
if [ "x"$fsource = "xDigitalCamera" ]; then
mv -v $source/$file $target
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment