The following script is suppose to do the following, similar to what was done here: Renaming field using ArcPy?.
- Create a fieldlist.
- Read thru the fieldlist and create a new field named "OLD_" + field.name.
Copy the values in field to new field.
import arcpy, os intable = arcpy.GetParameter(0) fields = arcpy.ListFields(intable) try: for field in fields: if field.name == "OBJECTID" or field.name == "Shape" or field.name == "Shape_Length": pass else: field_name = field.aliasName old_field = field_name + "OLD_" field_precision = field.precision field_scale = field.scale field_length = field.length field_type = field.type arcpy.AddField_management(intable, old_field, field_type, field_precision, field_scale, field_length) arcpy.CalculateField_management(intable, old_field, "!"+field+"!") except: print arcpy.GetMessages() del intable, fields, field
- The script stops upon reaching the CalculateField_management code, which is one iteration, but there are approximately 50 more fields in the list that are ignored.
- The newly create field is empty, the values are not copied across.
I have tried everything and followed the example given in the link above, but nothing has fixed these two problems.