recursing through files in a folder
Mirko Zeibig
mirko-individual at zeibig.net
Fri Oct 1 13:51:40 EDT 2004
Larry Bates said the following on 10/01/2004 04:20 PM:
> 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
I'd opt for `optparse` instead of `getopt` ;-). Since Python 2.3 it's
included in the distribution, for older version search for `optik`,
which is the old name of `optparse`.
Regards
Mirko
More information about the Python-list
mailing list