import arcpy from arcpy import env env.workspace = r"C:\DATA" for shapefile in arcpy.ListFeatureClasses("*"): name = shapefile.split(".")[0] arcpy.AddField_management(shapefile, "RTENO", "TEXT") arcpy.CalculateField_management(shapefile, "RTENO", '"' + name + '"', "PYTHON")
Thank you both. This was a huge time saver. Really wish I was more comfortable with scripting tools. The time I could have saved.
Hi, i know it's an old conversation but you don't know why it doesn't work for me?
var AL016 = "MS_FT_AL016_T"; var typObjektu = "TYP_OBJEKTU"; var NF103 = "MS_FT_NF103_T"; var NF109 = "MS_FT_NF109_T"; var NF121 = "MS_FT_NF121_T"; var NF127 = "MS_FT_NF127_T"; var NF128 = "MS_FT_NF128_T"; var FTJmeno = "MS_FT_JMENO_P_T"; List<string> names = new List<string>(); names.Add(AL016); names.Add(NF103); names.Add(NF109); names.Add(NF121); names.Add(NF127); names.Add(NF128); names.Add(FTJmeno); foreach (var name in names) { FeatureLayer featureLayer = mv.Map.FindLayers(name).First() as FeatureLayer; FeatureClass fc = featureLayer.GetTable() as FeatureClass; await AddField(fc, typObjektu, "TEXT", "", "", 10); object[] paraList = { fc, typObjektu, '"' + name + '"' }; //always comes NULL in the column await StartATask("management.CalculateField", paraList); }
Does this work for Ratsers too?
I don't think, with a few changes, where the feature classes are mentioned, I denoted Rasters - but nothing works!!!
Also, the simple %name% - doesn't work!!
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.