recursing through files in a folder

Larry Bates lbates at syscononline.com
Fri Oct 1 16:20:33 CEST 2004


Scott Carlson wrote:
> New to Python.  Very new.
> 
> I need to pass a parameter to the program I create that points to a
> folder.  (How are params passed in?)
> 
> Then, I need to be able to scroll through each file in the folder,
> looking for files with a particular naming convention.
> 
> What is the best way to be able to look at each file in a folder and
> decide if I wish to use that one, and then go to the next file?
> 
> Thanks,
> Scott

Use getopt to pick up the root directory from call line
Use os.path.walk to walk each of the files/directories
Use glob.glob to get a list of files that match

Larry Bates



More information about the Python-list mailing list