User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 401,605 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,743 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 276 | Replies: 1
Reply
Join Date: Apr 2008
Posts: 9
Reputation: drjekil is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
drjekil drjekil is offline Offline
Newbie Poster

need python user need help!folder!

  #1  
May 9th, 2008
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 538
Reputation: ZZucker is on a distinguished road 
Rep Power: 2
Solved Threads: 15
ZZucker's Avatar
ZZucker ZZucker is offline Offline
Posting Pro

Re: need python user need help!folder!

  #2  
May 9th, 2008
With Python that is a simple task:
  1. import os
  2.  
  3. # list just the files in a given folder
  4. folder = 'C:/Temp'
  5. for (paths, dirs, files) in os.walk(folder):
  6. # testing, this shows a list of filenames
  7. print files
  8. # now loop through the list of filenames
  9. for filename in files:
  10. # testing
  11. print filename
  12. # now enter code to process each of your files
  13. # ...
  14.  
Never argue with idiots, they'll just bring you down to their level and beat you with their experience.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 5:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC