Home > Back-end >  Fix needed to syntax bypass native cmd limitation[multilineEcho]OR able to pipeout multivalues from
Fix needed to syntax bypass native cmd limitation[multilineEcho]OR able to pipeout multivalues from

Time:07-24

I'm facing an issue while dealing with this syntax:

cmd /U /k ffmpeg -i "C:\any-video.avi" -af silencedetect=noise=-50dB:d=0.1 -f null - 2>&1 | FOR /F "tokens=8" %f in ('findstr "silence_duration:"') do @echo %f >>"C:\!TEMP.txt" 2>&1 & type "C:\TEMP.txt"

As I did had to use Echo to display the output on console to then after be able to printout to the file(otherwise if nothing in place it doesn't printsout), I was also forced to use it as Append(>>),and not(>) that would be ideal for me since I don't want to keep combining different file outputs, Because while Echo is able to print to console with all its outputs when multiple requested strings were found, when using it with(>) printing to file this way will just save to file the last string of multiple strings found and not all;

Then, I need a solution to this syntax be able to bypass the native cmd limitation of multiline Echo to a file with ">" OR another possible way to fully pipeout multiple strings found from a "IN (...)" clause of a "FOR" command OR any other option to print-to-file all the data found in these circuntances without using a batch file.

CodePudding user response:

SOLUTION: Stephan's fix on this case:

cmd /U /k ffmpeg -i "C:\any-video.avi" -af silencedetect=noise=-50dB:d=0.1 -f null - 2>&1 | (FOR /F "tokens=8" %f in ('findstr "silence_duration:"') do @echo %f) >"C:\!TEMP.txt" 2>&1 & type "C:\TEMP.txt"

Thank you. ~

  • Related