change test to -d to only rm -rf directories that exist at the target