Tuesday, 18 April 2017

bash - How to merge all WAV files appearing on the same line in a list?

I wanted to see if it was possible to do this in one line. I think I have it here.


cat  | xargs -L 1 printf "%s\n" | xargs -I {} sox {} m%4n.wav gain 0 : newfile

cat will read your file ( replace with your filename) and pipe into xargs, which will treat each line of the file as space separated arguments.


Use print to print each arg on a new line.


Use xargs again to recombine the arguments (each on a new line), using the -I argument so we can put the arguments at the front of thesox command and pass additonal arguments (you can't use -I and -L at the same time, otherwise you'd only need one xargs).


Use the sox gain filter set to 0 so we can chain the pseudo newfile filter to create a new file each time with the pattern m####.wav


Edit: nevermind, this doesn't quite work. It's still sending each file as an individual argument. Maybe someone with more command line-fu can do better. The script approach is probably more readable anyhow.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...