in reply to directory?
It's easy to test whether something is a directory using the -d function. See the documentation on functions for more details.
Hope this helps, -gjb-