user3514446
user3514446

Reputation: 77

Robocopy python script running whole command as source

I have the following line in my script:

subprocess.call([r"robocopy", "\\\\stockholm\exam$\ \\\\stockholm\exam_temp$\ /e /move"])

Which fails when I run it as Robocopy thinks that the whole line is the source address and has no destination. Could someone tell me what's wrong with my syntax? If I run the same line in CMD (minus the extra \'s etc obviously) it works perfectly!

Many thanks, Chris.

Upvotes: 0

Views: 2701

Answers (3)

odedpr
odedpr

Reputation: 147

you can pass a list - for e.g.

command_to_pass = ["robocopy", src, dst, extra_args]

call(command_to_pass)

Upvotes: 0

yorodm
yorodm

Reputation: 4461

You need to scape de \'s or use raw strings

subprocess.call([r"robocopy", r"\\stockholm\exam$\ \\stockholm\exam_temp$\ /e /move"])

Upvotes: 1

user3535644
user3535644

Reputation: 149

try to pass args as list, es.

subprocess.call([r"robocopy", "\\\\stockholm\exam$\","\\\\stockholm\exam_temp$\","/e","/move"])

I'm not not sure about extra \'s.

Upvotes: 0

Related Questions