Check the result of glob first before iterating