我正在尝试使用解包程序来提取多个文件。我的脚本是这样的
for /R %%i in (*.ext) DO quickbms.exe -o script.bms "%%i" "%%~ni"
问题是,当我从 C:\archives
中删除文件时,它会将所有文件提取到该目录,包括 C:\archives\dir1
中的存档,C:\archives\dir2
、等
如何将所有存档提取到各自的文件夹中,而无需手动启动每个文件夹中的脚本?
最佳答案
for /R %%i in (*.ext) DO quickbms.exe -o script.bms "%%~i" "%%~dpni"
请阅读for/?
:可以组合修饰符以获得复合结果。
作者:Command Line arguments (Parameters) :
- …
%~f1
Expand%1
to a Fully qualified path name -C:\utils\MyFile.txt
%~d1
Expand%1
to a Drive letter only -C:
%~p1
Expand%1
to a Path only e.g.\utils\
this includes a trailing\
which will be interpreted as an escape character by some commands.%~n1
Expand%1
to a file Name without file extensionC:\utils\MyFile
or if only a path is present (with no trailing backslash) - the last folder in that path.- …
您的 "%%~pi\%%~ni"
将导致(就上面的示例而言)\utils\\MyFile.txt
(注意两个连续的\\
反向实体)。
幸运的是,批处理解释器将路径中的双\\
(甚至多个)反斜杠视为单个\
反向斜线...
关于batch-file - batch - 当前批量处理的文件的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39987196/