为什么我得到以下批处理参数替换中路径运算符的用法无效 [英] why I am getting The following usage of the path operator in batch-parameter substitution is invalid
问题描述
我有一个批处理文件,它应该获取一个目录并使用我拥有的应用程序处理其中的所有 jpeg 文件.
I have a batch file which should get a directory and process all jpeg files in it using an application that i have.
批处理文件是:
for %%I in (%1\*.jpg) do (
bin\process.exe %%I "%~dpI\output\%~nxI"
)
但是当我运行这个批处理文件时,我收到这个错误:
but when I am running this batch file, I am getting this error:
batch-parameter中路径操作符的以下用法替换无效:%~dpI\output\%~nxI"
The following usage of the path operator in batch-parameter substitution is invalid: %~dpI\output\%~nxI"
我阅读了格式说明符,它说:
I read the format specifier and it says:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
基于它,语法应该是正确的?
based on it, the syntax should be correct?
有什么问题?
推荐答案
在批处理文件中,当您使用 for 循环变量时,您需要 两个 % 符号.像 %I 这样的变量只用于命令行.你应该说
Inside a batch file, you need two % symbols when you're using the for loop variables. Variables like %I would only be for the command line. You should be saying
for %%I in (%1\*.jpg) do (
bin\process.exe %%I "%%~dpI\output\%%~nxI"
)
这篇关于为什么我得到以下批处理参数替换中路径运算符的用法无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!