[Tutor] processing files in a directory

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri, 7 Sep 2001 10:56:03 -0700 (PDT)


On Fri, 7 Sep 2001, Tzu-Ming Chern wrote:

> Basically I would like to go into a single directory and a run my
> other script on those individual files present in the directory. I'm

Using the glob.glob() function will give you a list of files in a specific
directory:

###
>>> glob.glob('*.txt')
['notes.txt']
###

This works identically to Perl's globbing operator '<>'.


> having headaches using perl to try and process these files since I
> keep overwriting the files. Is there an easier solution?

Hmmm!  Can you explain a little more about how you're processing the
files?  Are you replacing content in each of those files?