开发者

SVN Batch Rename Whitespace Issue

开发者 https://www.devze.com 2023-04-09 19:22 出处:网络
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:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消