我试图使用 FFMPEG 将 .flac 的文件夹批量转换为 .mp3,但是当我运行我的批处理文件时,我得到了“%F 此时意外”错误,即使我在批处理中使用了“%%F”文件。为了测试真正的问题是什么,我直接将 %F 的变体输入到 cmd 中,但也无法让它工作。 Windows 10 在 for 循环中使用变量名有什么变化吗?
我试过的cmd命令:
C:\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy>for "%F" in (*.flac) echo %F
"%F" was unexpected at this time.
C:\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy>for %F in (*.flac) echo %F
echo was unexpected at this time.
C:\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy>for "%%F" in (*.flac) echo %%F
"%%F" was unexpected at this time.
C:\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy>for "%f" in (*.flac) echo %f
"%f" was unexpected at this time.
C:\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy>for "%g" in (*.flac) echo %g
"%g" was unexpected at this time.
C:\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy>for "%g" in ("*.*") echo %g
"%g" was unexpected at this time.
C:\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy>for "%g" in ("*.*") do echo %g
"%g" was unexpected at this time.
FFMPEG 的原始批处理文件
cd "\Users\yt\Music\Joe Hisaishi (Classical Guitar) - Copy"
echo in directory "%cd%"
pause
for "%%F" in ("*.flac") do (
echo converting "%%F"
"C:\Users\yt\Downloads\OtherApps\FFMPEG\bin\ffmpeg.exe" -i "%%F" -codec:a libmp3lame -qscale:a 2 "%%~nF.mp3"
echo del "%%F"
)
cd "%~dp0"
最佳答案
不要使用
FOR "%F" ...
在命令行上但是
FOR %F ...
在脚本中你必须使用
%%
而不是 %
:FOR %%F ...
但不是
FOR "%%F" ..
"%G"
的原理相同( "%%G"
),使用 %G
( %%G
) 代替
关于windows - %a 和 %%a 突然分别在 Win 10 cmd 和批处理文件中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41648655/