Skip to content

Instantly share code, notes, and snippets.

@filviu
Created August 18, 2014 08:39
Show Gist options
  • Save filviu/c6765196d2c9aa15c470 to your computer and use it in GitHub Desktop.
Save filviu/c6765196d2c9aa15c470 to your computer and use it in GitHub Desktop.
Search and clean duplicate phosts (useful if switching to lightroom from digikam)
#!/bin/bash
# cleanup and revert to RAW only library after switching to lightroom after using digikam
# only prints results
PHOTOS_FOLDER="/home/photos"
while read RAWFILE; do
rawpath=$(dirname "$RAWFILE")
filename=$(basename "$RAWFILE")
extension="${filename##*.}"
filename="${filename%.*}"
if [ -f "$rawpath"/"$filename".JPG ]; then
echo "Found "$rawpath"/"$filename".JPG for $RAWFILE"
fi
if [ -f "$rawpath"/"$filename".jpg ]; then
echo "Found "$rawpath"/"$filename".jpg for $RAWFILE"
fi
# those are particular to my usage during the transition times
if [ -f "$rawpath"/LR_"$filename".JPG ]; then
echo "Found "$rawpath"/LR_"$filename".JPG for $RAWFILE"
fi
if [ -f "$rawpath"/LR_"$filename".jpg ]; then
echo "Found "$rawpath"/LR_"$filename".jpg for $RAWFILE"
fi
# yes regex would be better here for v1, v2, etc
if [ -f "$rawpath"/"$filename"_v1.JPG ]; then
echo "Found "$rawpath"/"$filename"_v1.JPG for $RAWFILE"
fi
if [ -f "$rawpath"/"$filename"_v1.jpg ]; then
echo "Found "$rawpath"/"$filename"_v1.jpg for $RAWFILE"
fi
if [ -f "$rawpath"/"$filename"_v2.JPG ]; then
echo "Found "$rawpath"/"$filename"_v2.JPG for $RAWFILE"
fi
if [ -f "$rawpath"/"$filename"_v2.jpg ]; then
echo "Found "$rawpath"/"$filename"_v2.jpg for $RAWFILE"
fi
done < <(find $PHOTOS_FOLDER -iname *.CR2 | sort)
echo
# again particular to my usage
# had a few months when I used digikam for management and LR for processing
while read JPGFILE; do
rawpath=$(dirname "$JPGFILE")
filename=$(basename "$JPGFILE")
extension="${filename##*.}"
filename="${filename%.*}"
if [ -f "$rawpath"/LR_"$filename".JPG ]; then
echo "Found "$rawpath"/LR_"$filename".JPG for $JPGFILE"
fi
if [ -f "$rawpath"/LR_"$filename".jpg ]; then
echo "Found "$rawpath"/LR_"$filename".jpg for $JPGFILE"
fi
if [ -f "$rawpath"/"$filename"_v1.JPG ]; then
echo "Found "$rawpath"/"$filename"_v1.JPG for $JPGFILE"
fi
if [ -f "$rawpath"/"$filename"_v1.jpg ]; then
echo "Found "$rawpath"/"$filename"_v1.jpg for $JPGFILE"
fi
if [ -f "$rawpath"/"$filename"_v2.JPG ]; then
echo "Found "$rawpath"/"$filename"_v2.JPG for $JPGFILE"
fi
if [ -f "$rawpath"/"$filename"_v2.jpg ]; then
echo "Found "$rawpath"/"$filename"_v2.jpg for $JPGFILE"
fi
done < <(find $PHOTOS_FOLDER -iname *.JPG | sort)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment