Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@metodribic
Created August 24, 2018 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metodribic/7890375237051a7ebe716d85c1da05f2 to your computer and use it in GitHub Desktop.
Save metodribic/7890375237051a7ebe716d85c1da05f2 to your computer and use it in GitHub Desktop.
Remove all CR2 (raw image) files if they don't have corresponding JPG sibling
#!/bin/bash
# Remove all CR2 (raw image) files if they don't have corresponding JPG sibling
allJpgs="$(ls|grep .JPG)"
allRaws="$(ls|grep .CR2)"
allowedRaws=()
for file in $allJpgs
do
allowedRaws+=(${file/JPG/CR2})
done
for raw in ${allRaws[@]}
do
if [[ ! " ${allowedRaws[@]} " =~ " ${raw} " ]]; then
echo "Removing $raw"
rm $raw
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment