I require the script to cd to a directory, then delete all but a few files in sub-directories—but leave the folders alone. Would it help to use switch
You should use find :
for i in $(find . -type d)
do
do_stuff "$i"
done
If you really have a lot of directories, you can pipe the output of find into a while read loop, but it makes coding harder as the loop is in another process.
About spaces, be sure to quote the variable containing the directory name. That should allow you to handle directories with spaces in their names fine.