这听起来很愚蠢,但我无法让它发挥作用.我想我只是不明白它们之间的区别%%v, %v% and %v
这是我正在尝试做的事情:
for %%v in (*.flv) do ffmpeg.exe -i "%%v" -y -f mjpeg -ss 0.001 -vframes 1 -an "%%v.jpg"
这会成功为每部电影生成缩略图,但问题是:
movie.flv -> movie.flv.jpg
所以我想做的是关闭最后4个字符%%v
并将其用于第二个变量.
我一直在尝试这样的事情:
%%v:~0,-3%
但它不起作用,也没有任何我能想到的迭代.
有任何想法吗?
对于发现此线程正在寻找如何在for-loop变量上实际执行字符串操作的人(使用延迟扩展):
setlocal enabledelayedexpansion ... ::Replace "12345" with "abcde" for %%i in (*.txt) do ( set temp=%%i echo !temp:12345=abcde! )
for %%v in (*.flv) do ffmpeg.exe -i "%%v" -y -f mjpeg -ss 0.001 -vframes 1 -an "%%~nv.jpg"
从"帮助":
%~I - expands %I removing any surrounding quotes (") %~fI - expands %I to a fully qualified path name %~dI - expands %I to a drive letter only %~pI - expands %I to a path only %~nI - expands %I to a file name only %~xI - expands %I to a file extension only %~sI - expanded path contains short names only %~aI - expands %I to file attributes of file %~tI - expands %I to date/time of file %~zI - expands %I to size of file %~$PATH:I - searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string
使用%% ~nV仅获取文件名.