Wednesday, February 15, 2017

python loop through subdirectories


Probably one of the weirdest python code i have ever seen to loop through files in a directory. But i think its pretty efficient.


for subdir, dirs, files in os.walk("."):
    for file in files:
        print os.path.join(subdir, file)


-Yay! prints all the files in a directory.

No comments: