0

this is the batch

for /f "skip=9 tokens=1-3" %%x in ('sox.exe Heavyrainambienc2801.wav -n stat') do (
  if "%%x %%y"=="Maximum delta:" set maxDelta=%%z
)
echo %maxDelta%

and instead of max delta value I'm getting blank echo

Samples read:          11832320
Length (seconds):    123.253333
Scaled by:         2147483647.0
Maximum amplitude:     0.999939
Minimum amplitude:    -0.999969
Midline amplitude:    -0.000015
Mean    norm:          0.488960
Mean    amplitude:    -0.000082
RMS     amplitude:     0.570900
Maximum delta:         1.999878
Minimum delta:         0.000000
Mean    delta:         0.651948
RMS     delta:         0.807396
Rough   frequency:        10804
Volume adjustment:        1.000

Try: -t raw -e mu-law -b 8

C:\1>echo
ECHO is on.

I'm not sure this is important but it is run on Windows 10

  • your code is fine. Is it [within another code-block](http://stackoverflow.com/a/30284028/2152082)? – Stephan Aug 26 '16 at 09:50
  • 1
    PLEASE provide a SPECIFIC question TITLE!! How is the output of `sox.exe` formatted -- ANSI/Unicode? – aschipfl Aug 26 '16 at 09:54
  • no, it is separate code, I don't know about formatting of the sox.exe – Piotr Fraczek Aug 26 '16 at 10:09
  • 2
    If you know that the line # 10 have the info you want, why do you add the `if` command? Just take the third token at such line... – Aacini Aug 26 '16 at 13:25
  • I meant the **output** of `sox.exe`, not the application itself; try to do the following: `sox.exe Heavyrainambienc2801.wav -n stat > "\path\to\file.txt"`, then open the returned file `file.txt` with Notepad and go to "File » Save As..."; in the "Save As" dialog, what is selected in the "Encoding:" field? – aschipfl Aug 26 '16 at 14:48

1 Answers1

0

I am not sure what the mistake is, but there is a workaround: Place the output of the command you are using in a text-document and read it from there. That worked for me.

I directly copied the block of text into the file to test it; if there is something else you might want to check if %%x and %%y are the desired values. If they are not, you know where to take a closer look :)

At the end of the batch script, you can just delete the file.

@echo off
sox.exe Heavyrainambienc2801.wav -n stat 2>output.txt
for /f "skip=9 tokens=1-3" %%x in (output.txt) do (
if "%%x %%y"=="Maximum delta:" set maxDelta=%%z
)
echo %maxDelta%
del output.txt
pause
geisterfurz007
  • 5,292
  • 5
  • 33
  • 54