Looping through files in a directory

Chris Rebert clp2 at rebertia.com
Wed Nov 10 19:43:10 EST 2010


On Wed, Nov 10, 2010 at 2:46 PM, Matty Sarro <msarro at gmail.com> wrote:
> Short story - I have a few thousand files in a directory I need to parse
> through. Is there a simple way to loop through files? I'd like to avoid
> writing a python script that can parse 1 file, and have to call it a few
> thousand times from a bash script. Any input or pointers to functions that'd
> help would be very much appreciated. Thanks!

http://docs.python.org/library/os.html#os.listdir
http://docs.python.org/library/os.html#os.walk

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list