Updated Answer
I think the following code may be closer:
#!/bin/bash
index=0
while read this; do
if [ $index -gt 0 ]; then
d=$(bc <<< "$this - $start")
echo sox audio.wav new-$index.wav trim \"$start\" \"$d\"
fi
((index+=1))
start=$this
done < times.txt
I don't use sox, but this is the gist of the approach - it assumes your times are in a file called times.txt
:
#!/bin/bash
index=0
while read this; do
if [ $index -gt 0 ]; then
echo sox audio.wav new-$index.wav trim $start $this
fi
((index+=1))
start=$this
done < times.txt
Sample Output
sox audio.wav new-1.wav trim 0.0 6.16
sox audio.wav new-2.wav trim 6.16 13.44
sox audio.wav new-3.wav trim 13.44 17.54
sox audio.wav new-4.wav trim 17.54 23.3
sox audio.wav new-5.wav trim 23.3 26.5
So you would save all that code in file called $HOME/trimmer
then start Terminal and run the following to make the script executable - just once is sufficient:
chmod +x $HOME/trimmer
Then change directory to where your audio files are, e.g.:
cd path/to/audio/files
then run the script with:
$HOME/trimmer
If you like how it looks, remove the word echo
from the script and run it again. Please make a backup first if you are unfamiliar with scripting.