I´m trying to use a variable as part of the output path of a shutil command. Unfortunately I couldn´t work it out how to do it. Can anybody help?
import arcpy
import shutil
Name = arcpy.GetParameterAsText(0)
shutil.copyfile("C:\\test.txt", "C:\\%Name%.txt")
This question here is similar, but was never answered: Using ArcGIS ModelBuilder to perform In-line variable substitution for input data path?
outfilename = "C:\\" + str(outbasename) + ".txt"– Michael Markieta Jul 20 '12 at 13:45outfilename="C:\\%s.txt" % (outbasename)The%smeans that a string is substituted at that location from the tuple that follows (in this case containing only the variable outbasename, which will be coerced to a string). – blord-castillo Jul 20 '12 at 14:23