Linuxer
Linuxer

Reputation: 21

Wav to mp3 bash script

I can't figure out why the script isn't working, I don't get any syntax error, It just does nothing and delete the files

#!/bin/bash
recorddir="${1:-/var/spool/asterisk/mp3/}"
cd $recorddir;
for file in *.wav; do
mp3=$(basename "$file" .wav).mp3;
lame V3 "$file" "$mp3";
mv "$mp3" /var/spool/asterisk/rec;
rm -f "$file";
done

Upvotes: 0

Views: 876

Answers (1)

viraptor
viraptor

Reputation: 34145

You're missing - in front of V3 for sure. Otherwise, this is just a very messy script. If there's something more that doesn't work:

  • add proper indentation
  • strip unnecessary semicolons (they're not needed at the end of the lines - only before do in this script)
  • set the options that make this script abort on failures and undefined vars: set -eu
  • quote all variables (most are already ok, but $recorddir isn't)

Upvotes: 1

Related Questions