Skip to main content
deleted 72 characters in body
Source Link
RyanKDalton
  • 23.2k
  • 17
  • 112
  • 180

You need to use arcpy.ListFeatureClasses(), not ListDatasets().

This code is directly from the online help. Just replace "CopyFeatures" with "Rename". Please try to do a little bit of research before posting a question.

import arcpy
from arcpy import env
import os

# Set the workspace for the ListFeatureClass function
#
env.workspace = "c:/base"

# Use the ListFeatureClasses function to return a list of 
#  all shapefiles.
#
fcList = arcpy.ListFeatureClasses()

# Copy shapefiles to a file geodatabase
#
for fc in fcList:
    arcpy.CopyFeatures_management(fc, "d:/base/output.gdb" + os.sep + fc.rstrip(".shp"))

You need to use arcpy.ListFeatureClasses(), not ListDatasets().

This code is directly from the online help. Just replace "CopyFeatures" with "Rename". Please try to do a little bit of research before posting a question.

import arcpy
from arcpy import env
import os

# Set the workspace for the ListFeatureClass function
#
env.workspace = "c:/base"

# Use the ListFeatureClasses function to return a list of 
#  all shapefiles.
#
fcList = arcpy.ListFeatureClasses()

# Copy shapefiles to a file geodatabase
#
for fc in fcList:
    arcpy.CopyFeatures_management(fc, "d:/base/output.gdb" + os.sep + fc.rstrip(".shp"))

You need to use arcpy.ListFeatureClasses(), not ListDatasets().

This code is directly from the online help. Just replace "CopyFeatures" with "Rename".

import arcpy
from arcpy import env
import os

# Set the workspace for the ListFeatureClass function
#
env.workspace = "c:/base"

# Use the ListFeatureClasses function to return a list of 
#  all shapefiles.
#
fcList = arcpy.ListFeatureClasses()

# Copy shapefiles to a file geodatabase
#
for fc in fcList:
    arcpy.CopyFeatures_management(fc, "d:/base/output.gdb" + os.sep + fc.rstrip(".shp"))
Source Link
RyanKDalton
  • 23.2k
  • 17
  • 112
  • 180

You need to use arcpy.ListFeatureClasses(), not ListDatasets().

This code is directly from the online help. Just replace "CopyFeatures" with "Rename". Please try to do a little bit of research before posting a question.

import arcpy
from arcpy import env
import os

# Set the workspace for the ListFeatureClass function
#
env.workspace = "c:/base"

# Use the ListFeatureClasses function to return a list of 
#  all shapefiles.
#
fcList = arcpy.ListFeatureClasses()

# Copy shapefiles to a file geodatabase
#
for fc in fcList:
    arcpy.CopyFeatures_management(fc, "d:/base/output.gdb" + os.sep + fc.rstrip(".shp"))