I'm attempting to convert a number of shapefiles into a geodatabase and automate the process using python. The directories that contain the shapefiles that need to be converted are named by county for example "cass". The geodatabases are named after the counties as well but end in the extension .gdb and they end up looking like this "cass.gdb". I've already tried using the os.walk function for both directories and comparing them in order to put the correct files in the correct place but I simply end up with a loop that only compares one county file to one county .gdb without moving to the next item. I was wondering if anyone would know how to correct this problem, or have a more efficient way of doing it. Here is my code as it sits right now.
import arcpy import os arcpy.env.overwriteOutput inFile = "P://County_Map_Book//counties" outGeoPath = "P://County_Map_Book//mapbookCountiesGeodatabases" doubSlash = "//" #This compound loop structure walks #through directories of shapefiles for root, dirs, files in os.walk(inFile): for compare in dirs: compareShapes = compare for root, dirs,files in os.walk(outGeoPath): for compareGD in dirs: if compareGD.endswith(".gdb"): compareGDB = compareGD[:-4] for comp in compareShapes: if comp in compareGDB: print compareGDB + " shares name with " + compareShapes