Post Export Script

Hi friends,

Here’s a workflow that works well for me when sequencing albums/eps/etc.

The end product is a set of numbered and labelled wav files, which are then transcoded to mp3 files that are placed in a separate subfolder. After a few years of putting it off I’ve polished up my simple bash script and wanted to share it.

Despite not having burned a CD in well over a decade, I still use the CD Tracks markers almost every day along with a shell script called by the post-export command option. The shell script requires installation of shntool and lame.

I place each tune on its own track, applying any sort of ‘mastering’ (in quotes to signify I’m just a hobbyist) to each track, and placing CD Track markers to label/separate them.

I then export to WAV, selecting the “Create CUE file for disk-at-once…” option, and calling the following script in the Post-Export Command field:

#!/bin/bash

# Custom Ardour Export Script
# Dan Easley 20260419
# splits wav/cue filepair to separate wav files,
# transcodes all wav files to mp3 placed in subfolder

# Requirements:
#
# shntool and lame must be installed

# Usage:
#
# Within Ardour Export Profile editor,
# select metadata option "Create CUE file for disk-at-once..."
# and place this in Ardour Post-Export Command field:
#    /path/to/this-script.sh %d %f


# set working directory to export folder
cd "$1"

# split wav file into separate tracks
shnsplit -f "$2".cue -P none -O always -t "%n %t" -d "$1" "$2"

#transcode wav files to mp3
for file in *.wav
do lame --silent --preset extreme "$file"
done

# create mp3 folder (fail tolerably gracefully if already exists)
mkdir mp3

# move mp3 files to their own folder
mv *.mp3 mp3/

I’d be very pleased if this is of help to anyone else, and grateful if anyone has any ideas on improving it. :slight_smile:

1 Like

Thanks for sharing your script!

A couple of tweaks which might make it smoother:

  • mkdir -p <target> avoids failing if the directory exists: it also creates all the “parent” directories if they don’t exist.

  • lame --out-dir mp3/ foo.wav will make the MP3 output file in --out-dir/, rather than the same directory as the .wav file.

So, you could create the mp3/ subdirectory before the for loop, and then create the .mp3 files in it:

mkdir -p mp3/

for file in *.wav
do lame --silent --preset extreme --out-dir mp3/ "$file"
done