Maneuvering Around Directories w/Python in Windows

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

Really useful is the glob module.

import glob
for file in glob.glob(“*.*”):
    print file # print all file names in dir


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 ( and here (


Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s