Python Script for Running a Python Program over Different Filesinthe Directory

Peter Hansen peter at engcorp.com
Sat Mar 13 16:05:43 CET 2004


Shalen chhabra wrote:

> Thanks to all who responded: But my problem still remains unsolved:
> I can do for sure this:
> 
> import os
> 
> for f in os.listdir('/path/to/dir'):
>     <do stuff to f>
> 
> 
> But lets pay attention to my original post:

Don't be rude to those trying to help.  The answers given were perfectly 
appropriate to your somewhat unclear question.

> I said I want to run a python program.
> 
> For example: If i want to run a python program like this:
> 
> instead of <do stuff to f>
> 
> python program.py file1

In that case, investigate os.system(), as it will do what you need.

-Peter



More information about the Python-list mailing list