Put Shapefile name into attribute table

Discussion created by katze01 on Dec 3, 2013
Latest reply on Dec 4, 2013 by katze01
I iterate through a list of shapefiles and do some geoprocessing chains and field calculations for each of the input shapes (works fine).

The result is a dbf for each of the input shapefiles. Now I'd like to write the name of the input shapes into a field in the output dbf and then merge the dbfs. Merging works also fine. The naming process worked fine using ArcGIS 10 or 10.1, but fails using ArcGIS 10.2 and Python 2.7.3.

Some snippets:

#Blabla Environment + Import

#List FCs

name = []
x = 0
fcList = arcpy.ListFeatureClasses()

for fc in fcList:
    print fc
    name.insert(x, fc.split(".")[0])
    x += 1

#Blabla Geoprocessing


#Write Name into output dbf and merge
for fc in fcList:
        arcpy.AddField_management(input[x],"NAME", "TEXT")
        arcpy.CalculateField_management(input[x],"NAME", "name[x]", "PYTHON")
        x += 1   

out = outws + "Merge" + ".dbf"
result = arcpy.Merge_management (input, out)

Printing x, the input[x] and name[x] returns the right values for x and the file names (e.g. B, C, D, E, F). But only the first name is written into the table, e.g.:

0 --------    .    ------B
1 --------    .    ------B
2 --------    .    ------B
3 --------    .    ------B
4 --------    .    ------B

Any idea? By the way, I get now error message, but the info "returned exit code 0".