I think it has to do with the string value of your formula for calculating the name of the feature. Note the double quotes holding the name in single quotes by substituting string values in the third part of the arcpy.CalculateField_management() method.solution:
import os
import arcpy
fieldNameToAdd = "NAME"
try:
shpDir = r"C:\ShapeFileDir"
arcpy.env.workspace = shpDir
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
print "processing: %s" % (fc)
fcName = fc.split(".")[0]
fcPath = shpDir + os.sep + fc
# blah geoprocessing ...
#
#
#...
fLength = len(fcName)
# check if field "Name" already exists
existingFields = arcpy.ListFields(fcPath)
for field in existingFields:
print field.name
if field.name.lower() == fieldNameToAdd.lower():
print "the field named %s already exists. Try again or follow the commented instructions below." % (fieldNameToAdd)
#raise # exception
#OR
arcpy.DeleteField_management(fcPath, fieldNameToAdd)
# blah continue working
arcpy.AddField_management(fcPath,fieldNameToAdd, "TEXT", None, None, fLength)
arcpy.CalculateField_management(fcPath,fieldNameToAdd, "'%s'" % (fcName), "PYTHON")
# blah more geoprocessing...
except:
print "there was an error"
print arcpy.GetMessages()
#import traceback
#raise
#etc