BASH snippet – clean up stereo pairs and sort by folder L/R boom/lav

Assuming stardard protools L/R pairs.
Assuming existance of “boom” and “lav” paths.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

moveit(){

local channel=`echo ${filename} | cut -d . -f2`

if [ "$channel" == "L" ]
    then
        local newName="${filename/.L.wav/.wav}"
        cp ${filename} boom/$newName
    else
        local newName="${filename/.R.wav/.wav}"
    cp ${filename} lav/$newName
fi
}

########################### MAIN ########################
echo "-----------"
for filename in *.wav; do
    moveit $filename
done