Working a lot with SHP/TXT/KML files in Python on Windows, I have found it helpful to refresh my how-to memory :
To find out where you are:
import os
WorkingDirectory = os.getcwd()
To change directories:
import os
os.chdir(“NewWorkingDirectory”)
Really useful is the glob module if you want to read the contents of a directory into a list, and maybe iterate over that list…
import glob
for file in glob.glob(“*.*”):
print file # print all file names in dir
or
import glob
for shp in glob.glob(“*.shp”):
print shp # print names of all shapefiles in dir
Obviously, there is much more, e.g. os.path. See here (http://effbot.org/librarybook/os.htm) and here (http://docs.python.org/library/os.path.html).