16

I have a file geodatabase with several hundred feature classes in it.

Some feature classes have a field that got named incorrectly, and it got named "SCHEMA_FEATURECLASS_ENTITY" instead of just ENTITY. Consequently, their final destination (Oracle) complains about the very long field names.

I'd like to rename those fields to have their proper short name. I did find Changing feature class and field aliases in bulk using ArcPy? but (from what I understand) renaming a field is an add-copy-delete operation rather than just setting a property.

Has anyone got a quick-and-dirty method for doing a bulk rename? I have ArcCatalog 9.3.1 but NOT Visual Studio (client environment...).

0

7 Answers 7

11

You can use a Python script to do the heavy work for ya:

Check this out and adapt it to your needs. Needless to say, this is not tested, and don't use it on production data WITHOUT MAKING A BACKUP FIRST.

import arcgisscripting

gp = arcgisscripting.create(9.3)

gp.Workspace = "path_to_your_geodatabase"

# you can use absolute path to this function
gp.AddToolbox("management")

featureClasses = gp.ListFeatureClasses("*","ALL")

for featureClass in featureClasses:
    fields = featureClass.ListFields("*","ALL")

    for field in fields:

        # do not duplicate oid and geometry fields
        if field.Type == "OID" or field.Type == "Geometry":
            continue

        # lets refactor our field name
        # this transforms A_B_C into C
        fieldNames = field.Name.split("_")
        del(fieldNames[0:1])

        # add a new field using the same properties as the original
        # field
        gp.AddField(featureClass,fieldNames[0],field.Type)

        # calculate the values of the new field
        # set it to be equal to the old field
        gp.CalculateField(featureClass,fieldNames[0],field)

        # delete the old fields
        gp.DeleteField(featureClass,field)

I did not tested it, so test it and let me know if it works. If you need to change the name of the field in a different way, just alter the refactor part.

5

I don't believe anyone has mentioned this yet, but a very simple way to rename fields is to use the Make Table/Feature Layer in the Data Management toolbox.

Make Feature Layer Dialog Box Using this tool, you can specifiy a new name for your fields and then use the Copy Rows tool to create your new table with the appropriate field names.

Note: I know this works in ArcGIS10, but I cannot confirm the same functionality in 9.x

4

ET_GeoWizards lets you do bulk renames on featureclass fields in fGDBs. Can also change the data type and do bulk deletes as well.

However, you have to do it on one Feature class at a time.

It would not be too hard to put together some VBA/Python to perhaps achieve this. All depends on if the time to develop the code outweighs the time to manually doing it with an approach like using ET-GW

2
  • this is answering the wrong question. mwalker is asking about changing field names not feature class names. Commented Aug 19, 2010 at 17:29
  • I just typed it wrong. ET GW will do the job. Edited post.
    – jakc
    Commented Aug 20, 2010 at 2:52
3

I think you're stuck with the add->copy->delete method. In ArcCatalog, open ArcToolbox and go to Data Management Tools -> Fields and use the Add Field and Calculate Field tools. To do many features at once, right-click on the Add Field tool and choose Batch, then fill out the info for each feature class. Since your field name is going to be the same for each feature, you can fill in the first row of information and right click -> fill to populate the rest. Then do the same with the Calculate Field tool to calculate the values, and the same with Delete Field to delete the originals. I think this would be as fast (or faster) than trying to figure out a scripting solution.

3

Another method, requires Arcinfo and a lot of disk space: Export the personal or file geodatabase to normalised XML (inc. data), open the .xml in a decent text editor which can support huge files, search and replace SCHEMA_FEATURECLASS_ENTITY with ENTITY, save. Import the edited xml workspace document into an empty geodatabase. Voila.

1
  • Excellent method, and preserves your field order if you do it correctly. Commented Feb 2, 2012 at 23:14
3

As of ArcGIS 10.2.1 for Desktop, you can use Alter Fields (Data Management) with an Advanced level license to:

to rename fields or rename field aliases for any geodatabase table or feature class

The same tool became available to Basic and Standard level licenses at ArcGIS 10.2.2 for Desktop.

2

Erroneous answer about using MS Access to rename fields in a personal geodatabase in bulk has been removed. The method outlined corrupts the database. See the revision history if you're curious.

What does work is to open the .mdb in Access open the feature class table in Design View, and rename the field there, interactively. Don't touch any of the GDB_* tables. So it works, but not in bulk (though I suppose one could write a make table query for that?). This is also an easy method to re-order fields by the way.

4
  • 2
    I consider this a bit dangerous, but at the same time am (morbidly?) curious what happens. Careful with that axe. Commented Aug 19, 2010 at 4:13
  • 1
    This can badly break the geodatabase schema. I'm not sure of the actual consequences. Commented Aug 19, 2010 at 12:24
  • Are you renaming the field (column) on the actual table too? Again, not that I would ever condone such wreckless hacking. Commented Aug 19, 2010 at 14:44
  • I find this an intersting solution. There always seems to be some alarms going off when there is mention of using MS Access to work on a gdb/shp file, but from my experience, as long as certain parts of the file are not touched, nothing ends up crashing (that experience is only in Desktop environment). I think the main concern is that any Access-based route to working with ArcGIS is not supported/endorsed.
    – youzer
    Commented Oct 24, 2012 at 23:25

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