Hi all,
I have a very simple python script to copy a file from one location to another:
import shutil
shutil.copy("c:/chris/Test1/CitizenComments.mxd" , "c:/chris/test2/CitizenComments.mxd")
If I take this script and put it in a model builder model, what change would I have to make to the code so that I could have a parameter in the model where a user could enter an index string to be appended to the front of the file name?
Thanks!
Chrs
Solved! Go to Solution.
The most straightforward way would be something like the following, although you may run into trouble with /" (untested):
import shutil index = arcpy.GetParameterAsText(0) # get the first input parameter entered into the tool dialog shutil.copy("c:/chris/Test1/CitizenComments.mxd" , "c:/chris/test2/" + index + "CitizenComments.mxd")
To better work with paths, use os.path.join:
import shutil, os index = arcpy.GetParameterAsText(0) # get the first input parameter entered into the tool dialog shutil.copy("c:/chris/Test1/CitizenComments.mxd" , os.path.join("c:/chris/test2", index + "CitizenComments.mxd")
Thanks Darren. I'll play around with your suggestions.
Have a good weekend.
Chris