working with files with the same extenstion

Fredrik Lundh fredrik at pythonware.com
Mon Feb 4 19:36:33 CET 2002


Ulrich Pfisterer wrote:
> Can anyone please tell me how I would go about doing the following.
> I would like to write a script that would take in a command line
> parameter "*.txt". The script would then loop through every file with a
> "txt" extension and something with it.

import glob
for file in glob.glob("*.txt"):
    print "do something with", file

</F>





More information about the Python-list mailing list