I'm trying to batch rename some files in svn. I have an issue where some files have a space in them. when I try to run I get this error:
svn: Ca开发者_如何转开发nnot copy path '00009.png' into its own child '00009.png'
my code is:
import subprocess.call
call("svn rename " + "test 00009.png" + " test1 00009.png")
looks like it's splitting at the whitespace. any ideas?
Backslash escape your whitespace.
So:
import subprocess.call
call("svn rename " + r"test\ 00009.png" + r" test1\ 00009.png")
The r''
syntax means that python should treat the \
s literally, not as escapes in themselves. It passes them through svn where they are treated as escapes.
This should work:
call("svn rename " + "\"test 00009.png\"" + " \"test1 00009.png\"")
Basically surrounding all the paths with quotes, which you can easily do with say something like
"\"%s\"" % file
精彩评论