I know a folder’s path, and for every file in the folder I would like to do some operations. So essentially what I’m looking for is a for file in folder type of code that gives me access to the files in variables.
What is the Python way of doing this?
Thanks
EDIT – example: my folder will contain a bunch of XML files, and I have a python routine already to parse them into variables I need.
This will allow you to access and print all the file names in your current directory:
The os module contains much more information about the various functions available. The os.listdir() function can also take any other paths you want to specify.