How to process all files in a directory in Python

To process all files in a directory in Python you can use the following snippet.

Sample Python

import os

for filename in os.listdir(dirname):
    # do something
    pass

Please Share us:
Please rate this snippet

One thought on “How to process all files in a directory in Python

Leave a Reply