Last Updated: February 25, 2016
· kamilmichalak

Remove all empty directories frmo SVN tree

If you want to remove all versioned but empty directories from your SVC repository simply run this command inside of the VCS root

find . -name .svn -type d | while read ss; do dir=$(dirname "$ss"); test $(ls -a "$dir" | wc -l) == 3 && echo "svn rm \"$dir\""; done

The "find" searches for files files named .svn that are directories
The "while" assigns each line in the input to the variable ss
The "dirname" gets the parent directory of a path, the quotes are necessary for paths with spaces
ls -a should output 3 lines if the directory is in fact empty: ".", "..", and ".svn"
If the test is true and there are precisely 3 files in the directory, echo what we want to do
If the output of the one-liner looks good, pipe it to | sh to really execute