Skip to content

Instantly share code, notes, and snippets.

@soykanozcelik
Created July 8, 2026 20:56
Show Gist options
  • Select an option

  • Save soykanozcelik/45b0c1ff48dfc3fac1b38b4c5d273e10 to your computer and use it in GitHub Desktop.

Select an option

Save soykanozcelik/45b0c1ff48dfc3fac1b38b4c5d273e10 to your computer and use it in GitHub Desktop.
Remove Bin and Obj Folder
#!/bin/bash
# Constrain the allowable path in which to execute the actions.
# Assumes that your projects reside in ~/Projects
constrainedPath="$HOME/Projects"
if [ -z $1 ] ; then
exit 1
elif [[ $1 != *$constrainedPath* ]]; then
echo "Invalid path. The allowable path is constrained to $constrainedPath (and subdirectories) for safety"
exit 1
else
foldersToRemove=$(find $1 -type d \( -name bin -o -name obj \))
if [[ $foldersToRemove != "" ]]; then
echo "Removing folders:"
echo "$foldersToRemove"
rm -rf `find $1 -type d \( -name bin -o -name obj \)`
else
echo "No bin or obj folders to remove"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment