Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question
    
sox --i -D *.wav works here, are you in the correct directory? What does echo *.wav say? –  Thor Mar 31 at 9:00
1  
To 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 Mar 31 at 9:11
    
echo *.wav returns *.wav. Thanks for the for loop line! –  Frank Mar 31 at 21:51
    
I'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. –  Frank Mar 31 at 21:54
1  
Sorry I was under the misapprehension that you were running this in a different shell. cmd.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. –  Thor Apr 1 at 21:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.