Make sure that you use the updated version of the code instead of the first posting. The reason is that the updated version actually determines if is a directory based on the file attributes instead of just checking to see if it has a . to determine it is a file. Valid directories may have a . as part of their name in Windows.
Disregard this posting.