I have a bunch of files to sort.
Im trying to get a list of names of only files (or only folders) in directory.
path = 'C:\\test\\'
items = os.listdir(path) #this gives me a list of both files and folders in dir
for name in items:
if os.path.isfile(path + '\\' + name) == True:
items.remove(name)
I expected that items
would consist of folders' names. But it has also half of files' names.
However if I use print(name)
instead of items.remove(name)
it prints correctly.