Created
August 24, 2018 16:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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