I am trying to make a script in Python to recursively list all the files in a folder recursively. This code only shows some of the files in the directory I run it in, and I can't figure out why. Any help you can give me is much appreciated.
import os
def look(dir, indent_level = 0):
for each in os.listdir(dir):
if os.path.isfile(each):
print indent_level*' ' + each
if os.path.isdir(os.getcwd() + "/" + each):
print indent_level*'' + each
os.chdir(str(os.getcwd()) + "/" + each)
look(os.getcwd(), 4 + indent_level)
look(os.getcwd())