“for /f” 由于某种原因对我不起作用

huangapple go评论47阅读模式
英文:

"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
  )
)

huangapple
  • 本文由 发表于 2023年2月9日 02:13:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390071.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定