Last active
April 12, 2019 06:57
-
-
Save whtsky/b6aaee6592e22bf562a1a77dd7615987 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
clean_sdr_in_current_folder () { | |
find . -maxdepth 1 ! -path . -type d -print0 | while read -d $'\0' FOLDER | |
do | |
FOLDER=$(basename "$FOLDER") | |
if [[ $FOLDER == *".sdr" ]]; then | |
if [ -d "$FOLDER" -a ! -n "$(find . -maxdepth 1 -type f -name "${FOLDER%.sdr}*" -print -quit)" ] | |
then | |
echo "Remove $FOLDER" | |
rm -rf "$FOLDER" | |
fi | |
else | |
pushd "$FOLDER" | |
clean_sdr_in_current_folder | |
popd | |
fi | |
done | |
} | |
pushd documents | |
clean_sdr_in_current_folder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment