3

Does anyone know how to batch prepend one audio file to another audio file and create a separate output for each. E.g.

Files:

Static.wav
Audio1.wav
Audio2.wav
Audio3.wav

I need a script that can do the following:

Static.wav + Audio1.wav = Audio1out.wav
Static.wav + Audio2.wav = Audio2out.wav
Static.wav + Audio3.wav = Audio3out.wav
Static.wav + Audio*.wav = Audio*out.wav
(* = wildcard)

Thanks!

3 Answers3

5

Yet another update: This is similar to the solution provided here. This solution uses ffmpeg for conversion (which is something you don't need) and sox for combining the files.

You would only need to do download sox and use it. The script below will do what you want, but the output filenames would not be exactly how you want them to be. But you can handle the renaming part differently.

Create a shell script (combine.sh or some other name) with the following commands and run it whenever necessary:

for i in Audio*.wav
do
    sox -m Static.wav $i {$i}out.wav
done    

Please refer here for more information on using sox.

M K
  • 2,882
0

A fairly simple line would give you the output n.

echo $(cat file1)$(cat filen)
slhck
  • 235,242
0
file="madonna.wav"

do_combine () {
    input_filename="$@"

    # Strip the path
    input_filename="${input_filename##*/}"

    # Parameter expansion with input_filename below strips the extension
    cat "$file" "$input_filename" > "newfile.${input_filename%.*}.wav"
}

So you can do this:

do_combine "metallica.wav"

and the resulting file is named "newfile.wav" and is a combination of Madonna and Metallica, starting with the material girl herself.

cat is a legitimate method of combining wav files.

So if you wanted to combine all files in a specific direcory:

for file in /path/to/dir/*.wav
do
    do_combine "$file"
done

Might be a bug in there, it was done off the cuff. Having a program to combine madonna files would be really awkward to explain.

UtahJarhead
  • 2,077