I am trying to iterate through a directory and output if the current item is a file or a directory. This is the code I am trying to use
import os,time
dir = os.listdir("V:\\Inbox/")
for item in dir:
if os.path.isdir(item):
print "is Directory"
else:
print "is file"
You need to add the base dir to the path before passing it to
isdir.By the way, usually some
printstatements are a good thing to do before posting on SO (even though I don’t say no to easy rep from questions like these :P).