Note the mention of sox and ecasound for scripting audio processing stuff. I'm not familiar with either, but if Sox doesn't work for you, then maybe you should check out ecasound as an alternative. Here is the web site:
Audacity is primarily an interactive, graphical editor, not a batch-processing tool. Whilst there is a basic
batch processing tool it is experimental and incomplete. If you need to batch-process audio or do simple edits
from the command line, using sox or ecasound driven by a bash script will be much more powerful than audacity.