AnsweredAssumed Answered

Change field names with Python - new question

Question asked by jkbellamkonda on Feb 15, 2016
Latest reply on Mar 2, 2016 by Holisticbynature
Branched from an earlier discussion
# Import system modules
print "Importing modules"
import arcpy
import os

# Check out extensions and Overwrite outputs
print "Checking for extensions and Overwrite outputs"
arcpy.CheckOutExtension("Data Management")
arcpy.env.overwriteOutput = True

# Input Parameters
print "checking input Parameters"
infeature = arcpy.GetParameterAsText(0)
delete_fields = arcpy.GetParameterAsText(1)

# Delete unwanted fields
print "Deleting unwanted fields"
arcpy.DeleteField_management (infeature, [delete_fields])

# Alter field alias by capitalising the initial letter of the word.
print "Changing the field alias by turning 1st letter of the word to uppercase"
fields = arcpy.ListFields(infeature)
for field in fields:
   fname =
   alias = fname.title()
   arcpy.AlterField_management (infeature, field, alias)

print "done"

Hi Sephe Fox,

I have been trying to dig into this code to alter it to my specifications, but seems like I am lost. could you help me out with this please. Trying to create a script tool that allows you to delete fields and alter alias names.


Branched to new question by: Xander Bakker From original thread: