Python Script for Running a Python Program over Different Files in the Directory
Brett Kelly
inkedmn at inkedmn.com
Sat Mar 13 05:03:48 EST 2004
something like:
import os
for f in os.listdir('/path/to/dir'):
<do stuff to f>
that's the best way i know for doing something to each file in a directory...
On Sat, 13 Mar 2004 08:22:09 +0000, Shalen chhabra wrote:
> Hey,
>
> Can anyone give me a snippet for running a python program over all the files
> in the directory.
> For ex: I have ten files in a directory and I want to run a python program
> against all of these files, I wish to do the same using another python code
> instead of running each of these files one by one, which would be cumbersome
> giving the argv of each file every single time.
>
> This can be easily done using a shell script but I just wanted to have a
> flavour of python for this.
>
> Thanks
> Shalen
>
> _________________________________________________________________
> Fast. Reliable. Get MSN 9 Dial-up - 3 months for the price of 1!
> (Limited-time Offer) http://click.atdmt.com/AVE/go/onm00200361ave/direct/01/
More information about the Python-list
mailing list