Skip to content

Instantly share code, notes, and snippets.

@whtsky
Last active April 12, 2019 06:57
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 whtsky/b6aaee6592e22bf562a1a77dd7615987 to your computer and use it in GitHub Desktop.
Save whtsky/b6aaee6592e22bf562a1a77dd7615987 to your computer and use it in GitHub Desktop.
#!/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