fix removal of dirs for "remove" and "indexremove"

remove: Sort dirs so that subdirectories get deleted first
indexremove: don't use rmdir -p anymore, only rmdir