How do I tell a file from directory in Python?
Use os.path.isdir
to filter out the directories. Possibly something like
dirs = filter(os.path.isdir, os.listdir('/path'))
for dir in dirs:
# add your file
This might be faster:
current, dirs, files = os.walk('/path').next()
The list of directories will be in the dirs
variable.