I have a Geodatabase full of featureclasses. I want to perform the following:
- Copy out each individual featureclass as an output individual shapefile (and have the same name).
- Create individual Output Folders (of the same output shapefile name).
- Copy each output shapefile into its own unique folder (of the same name).
Currently, I can perform task 1 and 2 above, however, I am having trouble with task 3 above. My results so far is that I can create the output shapefiles and folders (of the same name), however, the shapefile outputs do not sit in the pertaining folders. i.e. My result = a bunch of shapefiles and a bunch of folders. I need to (i) either have the shapefiles created and automatically placed into the pertaining folder (based on the same name of the shapefile), or (ii) After creating the shapefiles and folders, move or copy the output shapefiles into each pertaining folder (based on the same name as the shapefile).
Therefore, for each of my featureclasses, my end result would be 1 seperate folder housing 1 shapefile (same name for both folder and shapefile).
I am fairly new to Python.
# import system modules import arcpy import os from arcpy import env # Set environment settings # Note: The INPUT Geodatabase below houses 5 x featureclasses env.workspace = r"D:\INPUT.mdb" arcpy.env.overwrite = True # Set local vairables # Note: Ensure that you have this empty folder already created within FileManager etc. outWorkspace = "D:/OutputFoldersAndSHP" print "Commencing" # Use the ListFeatureClasses function to generate a list of featureclasses in the env.workspace further above fcs = arcpy.ListFeatureClasses() for fc in fcs: # PHASE 1: CREATE A FOLDER BASED ON INDIVIDUAL FC NAMES # Note: (It simply uses the fc name as the output folder name!) arcpy.CreateFolder_management(outWorkspace, fc) # PHASE 2: COPY FEATURECLASSES TO SHAPEFILES # Determine the new output shp path and name outSHP = os.path.join(outWorkspace, fc) arcpy.CopyFeatures_management(fc, outSHP) print "Completed"