在 CMD .BAT 文件中,如何以编程方式仅删除“%~dp0”返回的路径中的最后一个斜杠?
这是为了解决我的命令失败
subst F: "%~dp0"
给予
S:\TLIB distribution\FG trial>subst F: "S:\TLIB distribution\FG trial\"
Path not found - S:\TLIB distribution\FG trial\
而
S:\TLIB distribution\FG trial>subst F: "S:\TLIB distribution\FG trial"
S:\TLIB distribution\FG trial>
成功。
最佳答案
选项 1:
pushd "%~dp0"
subst f: .
popd
选项 2:
for %%A in ("%~dp0\.") do subst f: "%~fA"
选项 3:
for %%A in ("%~f0\..") do subst f: "%~fA"
关于batch-file - 以编程方式仅删除 "%~dp0"返回的路径中的最后一个斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26254028/