dirpath is just a string, so there's no sense in putting it in a list and then iterating over that list. If you're trying to do something with each file in the tree: for dir, subdirs, names in os.walk(rootdir): for name in names: filepath = os.path.join(dir, name) + "-dummy" if not os.path.exists(filepath): f = open(filepath, 'w').write('')