英文:
"for /f " for some reason isn't working for me
问题
以下是您提供的代码的中文翻译部分:
setlocal enabledelayedexpansion
for %%b in (*.wav) do (
set duration=0
for /f "tokens=3,5" %%a in ('ffprobe -i "%%b" -show_entries format=duration -v quiet -of csv=p=0') do (
echo 'asdf' >> test.txt
)
)
请注意,代码中的注释和文件路径未包含在翻译中。如果您有任何其他问题,请随时提出。
英文:
setlocal enabledelayedexpansion
for %%b in (*.wav) do (
set duration=0
for /f "tokens=3,5" %%a in ('ffprobe -i "%%b" -show_entries format^=duration -v quiet -of csv^=p^=0') do (
echo 'asdf' >> test.txt
)
)
For some reason the above code isn't running properly. When I remove the "/f" part it works, but with the "/f" part it isn't setting the duration variable, I tried doing an "echo 'asdf' >> test.txt" inside of that loop as well and it doesn't work either, nothing I put into the "do" clause for the loop with /f is working.
Any ideas? I tried removing the "for %%b in (*.wav) do (" loop and didn't make a difference either.
Here's the output of ffprobe if I just run it by itself.
C:\Users\deama\Desktop\Empire\voiceacting_samples\gothic2\xardas>ffprobe -i OUTR
O_XARDAS_14_10.WAV -show_entries format=duration -v quiet -of csv=p=0
4.129546
C:\Users\deama\Desktop\Empire\voiceacting_samples\gothic2\xardas>
The script with the for loop is located in the same directory called "pop.bat".
答案1
得分: 0
以下是已翻译的内容:
看起来标记或其他内容出现了问题,以下部分有效:
for %%G in (*.wav) do (
for /F "delims=" %%H in ('ffprobe.exe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "%%G" 2>>&1') do (
echo %%H >> test.txt
)
)
英文:
Looks like something was wrong with the tokens or something, the following works:
for %%G in (*.wav) do (
for /F "delims=" %%H in ('ffprobe.exe -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%%G" 2^>^&1') do (
echo %%H >> test.txt
)
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论