DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   need python user need help!folder! (http://www.daniweb.com/forums/thread123383.html)

drjekil May 9th, 2008 9:48 am
need python user need help!folder!
 
i have a script which will do a specific task for a file in a folder,now i would like to do the same task for the all files in that folder(25 files).how can i do that?

Thanks in advance.

ZZucker May 9th, 2008 10:33 am
Re: need python user need help!folder!
 
With Python that is a simple task:
import os

# list just the files in a given folder
folder = 'C:/Temp'
for (paths, dirs, files) in os.walk(folder):
    # testing, this shows a list of filenames
    print files
    # now loop through the list of filenames
    for filename in files:
        # testing
        print filename
        # now enter code to process each of your files
        # ...


All times are GMT -4. The time now is 10:54 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC