find . -type d | tac | xargs rmdir 2>/dev/null
find will output all the directoriestac reverses the ordering of the lines, so "leaf" directories come first/dev/nullIn UNIX and BSD systems you might not have tac, you can try the less intuitive tail -r instead.
find . -depth -type d -empty -exec rmdir {} \;