开发者

convert backslashes to forward in batch files [duplicate]

This question already has an answer here: 开发者_如何转开发 Windows shell string operations (changing backslash to slash) (1 answer) Closed 9 years ago.

whats the easiest way of converting all backslashes to forward in a path in a batch file, since I need to use bash for execution.


SET "string=D:\path\to\folder"
ECHO %string:\=/%

Basically, you need first to store the string value into an environment variable, then use the following template:

%variable:str1=str2%

to replace every occurrence of str1 in variable with str2.

You can always remind yourself about this pattern by invoking SET /? from the command prompt.


echo 'C:\Program Files\Program' | sed -e 's/\\/\//g'
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜