Acting on Directories?
Hi, I'm a noob Python/Tkinter user, and I'm finding that gathering information on the two is not as easy as I'd like... hopefully you guys will be able to help. My first question: I was just wondering if there's a way to tell Python, "take all the files in X directory and do Y with each."
aot
Junior Poster in Training
83 posts since Feb 2007
Reputation Points: 10
Solved Threads: 1
Just to be clear: os.listdir() returns only the local filename, which often means that you need to attach the full path to get results:
import os
fullpath = "My/favorite/files/"
for filename in os.listdir(fullpath):
do_y(fullpath+filename)
Jeff
jrcagle
Practically a Master Poster
608 posts since Jul 2006
Reputation Points: 92
Solved Threads: 156