Skip to content

Instantly share code, notes, and snippets.

@nebgnahz
Created August 8, 2016 05:41
Show Gist options
  • Save nebgnahz/9805767d5ee987c10d854c94e627aa22 to your computer and use it in GitHub Desktop.
Save nebgnahz/9805767d5ee987c10d854c94e627aa22 to your computer and use it in GitHub Desktop.
Clean up SDCard. I normally scan my photos with JPG because it's much faster to load. And I will make changes, delete bad ones, during the scan. In the end, I want the corresponding CR2 whose JPG counterparts have been removed being cleaned. This script does the job.
#!/bin/sh
set -e
cd /Volumes/CANON/DCIM/100CANON;
for f in *.CR2
do
b=$(basename $f .CR2)
if [ ! -f "/Volumes/CANON/DCIM/100CANON/$b.JPG" ]; then
rm $b.CR2
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment