Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm fairly new to the arcpy world. I am trying to create a script in 10.0 that will load a dataset (file geodatabase) into ArcSDE and rename the feature classes with a prefix, i.e. San_Diego_Bay -> AJ_San_Diego_Bay. My script is below and is very basic for loading shapefiles into a geodatabase. I would like to load a file geodatabase into an ArcSDE Feature Dataset. Any help would be greatly appreciated.

import arcpy
from arcpy import env

# Set environment settings
env.workspace = "Z:/Data/Test_arcpy"

# Set local variables
inFeatures = ["Atlantic_Offshore_Areas.shp", "C_C_mauritania.shp", "E_Class.shp", "San_Diego_Bay.shp"]
outLocation = "Z:/Data/Test_arcpy/test_two_arcpy.gdb"

# Execute TableToGeodatabase
arcpy.FeatureClassToGeodatabase_conversion(inFeatures, outLocation)
share|improve this question

The attached script should help. The general idea here is to loop through your directory with a for loop and use Feature Class to Feature class to copy the shapefiles to a FGDB. When you define the output name, you have to strip the ".shp" extension or else you will receive errors.

# Import system modules
import arcpy
from arcpy import env

# Set workspace
env.workspace = "Z:/Data/Test_arcpy"
Dir = env.workspace

# Set local variables
out_path = "Z:/Data/Test_arcpy/test_two_arcpy.gdb"

# List the shapefiles in your directory
fclist = arcpy.ListFeatureClasses()

# Alternatively, create your own subset
#fclist = ["Atlantic_Offshore_Areas.shp", "C_C_mauritania.shp", "E_Class.shp", "San_Diego_Bay.shp"]

for fc in fclist:

    # Manipulate the string
    name = "AJ_" + str(fc.rsplit(".",1)[0])

     # Execute FeatureClassToFeatureClass
    arcpy.FeatureClassToFeatureClass_conversion(fc, out_path, name)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.