[GIS] ArcGIS Python – Convert feature class names to lower case

arcgis-desktoparcpypython

Can anybody anyone point me to directions on how to convert file geodatabase feature class names to lower case by using Python?

Best Answer

Using a combination of string manipulation and renaming the feature classes using arcpy.Rename_management works, sort of.

There's an odd problem with doing this directly. Since your output and input names are technically the same in ArcMap's opinion (this is apparently one of its operations that's case insensitive), it will complain if you just convert them directly.

fcList = arcpy.ListFeatureClasses()
for fcName in fcList:
    fcLCName = fcName.lower()
    arcpy.Rename_management(fcName, fcLCName, 'FeatureClass')

However, you can work around this by renaming to a dummy variable first, and then converting that to the actual lowercase name...

    arcpy.Rename_management(fcName, 'TEMPNAME', 'FeatureClass')
    arcpy.Rename_management('TEMPNAME', fcLCName, 'FeatureClass')