Windows shell 字符串操作(将反斜杠更改为斜杠) [英] Windows shell string operations (changing backslash to slash)

查看:90
本文介绍了Windows shell 字符串操作(将反斜杠更改为斜杠)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个脚本,该脚本采用当前路径 (%~dp0),将反斜杠转换为正斜杠并将其进一步传递给某个命令.

I need to write a script that takes the current path (%~dp0), transforms backslashes into forward slashes and passes it further to some command.

由于环境原因,我使用的唯一选项是 windows shell(不是 Powershell,问题不成问题).

Due to the environment I'm working in the only option that I have is windows shell (not Powershell where the issue would not a problem).

有可能做到吗?

推荐答案

set 命令有一个替换功能:

The set command has a substitution feature:

set a=C:\test\dir
set a=%a:\=/%
echo %a%

结果:

C:/test/dir

这篇关于Windows shell 字符串操作(将反斜杠更改为斜杠)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆