batch-file - batch - 当前批量处理的文件的目录

标签 batch-file batch-processing

我正在尝试使用解包程序来提取多个文件。我的脚本是这样的

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 extension C:\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/

相关文章:

c# - 设置进程调度程序的框架

sql-server - 批处理文件到 "Script"数据库

hadoop - hadoop是在单个计算机上管理数据批处理的可行解决方案吗?

node.js - Nodejs 和批处理作业

batch-file - 转到后批处理崩溃

batch-file - Windows 批处理 : reg query key value to a variable but do not display error if key doesn't exist

windows - "delims=#+#"- 多于 1 个字符作为分隔符

windows - 当字符串中有括号时如何用子字符串替换字符串

windows - 通过批量创建新文件而不覆盖旧文件

java - JdbcTemplate.update 输入从一个表到另一个表