For some work i was creating a tool which can add same field in attribute table of multiple feature classes. I wrote the script and it worked well but when i added this script to a tool; the tool didn't resulted in same results. I' m attaching screenshots for same. I'm kinda new to scripting and arcpy.
you need to use
so that the parameters are derived from the tool itself.
It is more fully described in
The process is the same for ArcMap and ArcGIS Pro
Your toolbox shows that the tool is called "Script1" which means that you didn't associate your script "add.py" to the toolbox properly. hence the error message. Notice that the path to your toolbox is called
You need to follow
all the sections in here
and in here
You will then get a properly formed and named toolbox with the script and its parameters correctly associated with the dialog.
dump all the parameters except for 0 and 1 for now
It seems that your first parameter is a multivalue parameter which return a semicolon delimited list of shapefiles. You will have to split that parameter on the semicolon and process each file in a 'for' loop. in fact, it doesn't even appear as a parameter in your original script, it is defined as a workspace and not featureclass(es).
Why don't you just run the existing tool in batch mode? (or can't you do that in arcmap? I can't remember)