using Sox to compare duration of an audio file with a variable

Asked

Viewed 16 times

0

good afternoon. I would like the help of the people. I am writing a scrip to separate songs in function from their duration in seconds using the soxi command of the Sox(apt install Sox) package. I want to compare the value obtained with a number to determine if the music is big or small. I tried the scrip below but not having success.

echo "Separando faixas..."

tamanho=$(soxi -D audio.flac)

if $tamanho < 330

      then
              echo "musica com tamanho normal"

      else
              echo "musica com tamanho grande"

      fi
echo "Feito."

1 answer

1

for those who need or find interesting, the result in seconds of the soxi command comes in floating point. then converted to integer with %.* and worked.

echo "Separating tracks..."

a=$(soxi -D audio.flac)
int=${a%.*}
echo $int "segundos"
b=330

      if [ $int -lt $b ]; then
              echo "tamanho normal" 
         
      else
              echo "tamanho grande" 
              
      fi
echo "Feito."

Browser other questions tagged

You are not signed in. Login or sign up in order to post.