Reputation: 159
so from within my code I am calling the subprocess module import subprocess
subprocess.call([r"robocopy", r"N:\\GIS\\Projects\\MarkTarrant_Data_Export", r"\\glenllsub1\\spatial\\LLS_Data\\Corporate_Data\\"])
This works fine and completes the copy !
But when I add the switch /S /E /MIR to the end it creates an error .
subprocess.call([r"robocopy", r"N:\\GIS\\Projects\\MarkTarrant_Data_Export", r"\\glenllsub1\\spatial\\LLS_Data\\Corporate_Data\\" /S /Z /MIR])
NameError: name 'S' is not defined
If I add theswitches to the end of the string
subprocess.call([r"robocopy", r"N:\\GIS\\Projects\\MarkTarrant_Data_Export", r"\\glenllsub1\\spatial\\LLS_Data\\Corporate_Data\\ /S /Z /MIR"])
It copies but creates switches as sub directories in the copied product not what I wanted.
Most likely a simple Noob errorI have overlooked!
Upvotes: 1
Views: 2543
Reputation: 715
Switches should be added as separate strings, separated by commas. Like this:
subprocess.call(
["robocopy", "N:\\GIS\\Projects\\MarkTarrant_Data_Export",
"\\glenllsub1\\spatial\\LLS_Data\\Corporate_Data\\", "/S", "/Z", "/MIR"]
)
Upvotes: 3