Handling directories with spaces Python subprocess.call()

Use a list instead:

task = ["svn",  "move",  "folder/hello world", "anotherfolder/hello world"]
subprocess.check_call(task)

If your file contains whole commands, not just paths then you could try shlex.split():

task = shlex.split(s)
subprocess.check_call(task)

Leave a Comment