I am trying to perform a batch of Altering field names through a stand alone python script using Arcpy but it seems I am making a basic mistake in my python code. Using a list I refer to the original field names and with another list I refer to the new field names. When I alter the fields through arcpy.AlterField_management I refer to elements in both lists.
When I run the script, I get the error that an 'Invalid value type for parameter field' is used.
What mistake am I making here?
This is the script:
import arcpy
orig_fieldName_List = ['C1S1_N_VL_SFS_cwIS', 'C1S1_R_VL_HPR_cwIS', 'C1S1_N_VL_APT_cwIS']
new_fieldName_List = ['C_N_SFS', 'C_R_HPR', 'C_N_APT']
fc = r'C:\Users\Jelle\My Documents\Test.gdb\test'
fieldList = arcpy.ListFields(fc)
for field in fieldList:
if field.name == orig_fieldName_List[0]:
arcpy.AlterField_management(fc, field, new_fieldName_List[0], new_fieldName_List[0])
if field.name == orig_fieldName_List[1]:
arcpy.AlterField_management(fc, field, new_fieldName_List[1], new_fieldName_List[1])
if field.name == orig_fieldName_List[2]:
arcpy.AlterField_management(fc, field, new_fieldName_List[2], new_fieldName_List[2])