从批处理文件中调用另一个批处理命令会停止进一步执行

发布于 2024-10-08 09:13:25 字数 404 浏览 0 评论 0原文

我在名为 scr 的文件夹中有一个 bat 脚本

/scr/
    script.bat
    test.txt 
    /folder/
        testinfolder.txt

当我想复制与脚本位于同一文件夹中的 test.txt 时,我像这样使用 %~dp0

copy %~dp0test.txt test.txt 

如果我想复制不在同一文件夹中的 testinfolder.txt 该怎么办文件夹作为运行脚本,但在文件夹内更深一层。我怎样才能复制该文件?我尝试过这个,但没有成功。

copy %~dp0/folder/testinfolder.txt testinfolder.txt

I have a bat script in a folder called scr

/scr/
    script.bat
    test.txt 
    /folder/
        testinfolder.txt

When I want to copy test.txt which is in the same folder as the script, I use %~dp0 like this

copy %~dp0test.txt test.txt 

What if I want to copy testinfolder.txt which is not in the same folder as the running script, but is one level deeper inside folder. How can I copy that file? I tried this, but it didn't work.

copy %~dp0/folder/testinfolder.txt testinfolder.txt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春庭雪 2024-10-15 09:13:25

怎么样

copy %~dp0folder\testinfolder.txt testinfolder.txt

How about

copy %~dp0folder\testinfolder.txt testinfolder.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文