0
I am trying to familiarize myself with sox to do some audio processing tasks. Ultimately, I want to take all my WAV files and extract just one channel, and save them, ideally with a modified name (e.g. input 55_55.wav would become left_55_55.wav). Right, now, though I'm just trying some basic stuff and encountering problems.
For example, looking at the duration of just one file works fine:
sox --i -D 55_55.wav
10.840000
But trying to run the command on all the .wav files in the directory doesn't work out:
sox --i -D *.wav
sox FAIL formats: can't open input file '*.wav': Invalid argument
What's going wrong here?
I tried several variations (e.g. ./*.wav
and changing the relative location of *.wav
) but haven't been able to solve it. I'm hoping to figure out how to do something to every .wav file in order to accomplish my goal, and it seems like using *.wav
for the input could be the right approach, but it's not working out so well. Any thoughts?
I thought something like the following lie would work out to extract one channel from every file and save that one channel with a modified name, but it seems I was a little too hopeful:
sox *.wav -c 1 left*.wav remix 1 0
sox FAIL formats: can't open output file `left*.wav`: Invalid argument
sox --i -D *.wav
works here, are you in the correct directory? What does echo *.wav say? – Thor – 2014-03-31T09:00:26.9501To extract the left channel from multiple files and save it separately you need to use a loop, e.g.
for wavfile in *.wav; do sox "$wavfile" "left_$wavfile" remix 1; done
. – Thor – 2014-03-31T09:11:24.657I'm pretty sure I'm in the right directory.
ls
returns all the files I expect, I can use the command on individual files, and the text before>
is the right directory. – Jota – 2014-03-31T21:54:55.873So your problem is that
*.wav
is not getting expanded, what shell are you running this in? Try running the loop in a bash shell. – Thor – 2014-04-01T07:42:06.4501
Sorry I was under the misapprehension that you were running this in a different shell.
– Thor – 2014-04-01T21:40:25.370cmd.exe
also supports for-loops, see for example this website. Something like this should work:for %wavfile in (*.wav) do sox %wavfile left_%wavfile remix 1
.