Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 this article on changing aliases 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...).

share|improve this question
add comment

6 Answers 6

up vote 9 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
2  
I consider this a bit dangerous, but at the same time am (morbidly?) curious what happens. Careful with that axe. –  Kirk Kuykendall Aug 19 '10 at 4:13
1  
This can badly break the geodatabase schema. I'm not sure of the actual consequences. –  George Aug 19 '10 at 12:24
    
Are you renaming the field (column) on the actual table too? Again, not that I would ever condone such wreckless hacking. –  Kirk Kuykendall Aug 19 '10 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 Oct 24 '12 at 23:25
add comment

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

share|improve this answer
    
this is answering the wrong question. mwalker is asking about changing field names not feature class names. –  matt wilkie Aug 19 '10 at 17:29
    
I just typed it wrong. ET GW will do the job. Edited post. –  Simon Aug 20 '10 at 2:52
    
thanks for the correction. –  matt wilkie Aug 20 '10 at 16:22
add comment

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.

share|improve this answer
    
Excellent method, and preserves your field order if you do it correctly. –  RyanDalton Feb 2 '12 at 23:14
add comment

Your Answer

 
discard

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.