gpt4 book ai didi

windows - 如何在 Windows 中获取批处理脚本的路径?

转载 作者:可可西里 更新时间:2023-11-01 11:51:25 28 4
gpt4 key购买 nike

我知道 %0 包含批处理脚本的完整路径,例如c:\path\to\my\file\abc.bat

我希望 path 等于 c:\path\to\my\file

我怎样才能做到这一点?

最佳答案

%~dp0 将是目录。 Here's some documentation on all of the path modifiers .有趣的东西:-)

要删除最后的反斜杠,您可以使用 :n,m 子字符串语法,如下所示:

SET mypath=%~dp0
echo %mypath:~0,-1%

不幸的是,我认为没有办法将 %0 语法与 :~n,m 语法结合起来。

关于windows - 如何在 Windows 中获取批处理脚本的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3827567/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com