Author Topic: little bash script (linux) FIXED  (Read 520 times)

0 Members and 1 Guest are viewing this topic.

Offline teloschistes

  • I Am Hydrogen
  • ****
  • Posts: 308
  • Karma: 8
  • ~ cerevisia mundum ferre possumus ~
little bash script (linux) FIXED
« on: April 07, 2006, 02:15:03 PM »
I posted the wrong version the other day!  Sorry about that.  It could handle flac, but not shn, due to a naming issue.  Anyway this one should work.  Report problems or whatever to daygh-at-riseup-dot-net.

For it to work, you have to have shorten, flac, and lame.
This is tested on a linux machine.  I don't know about bash on another os. 
Paste into editor.  Save as shnvbr or whatever.  Put it in your PATH, i.e., /usr/local/bin/  Make executable <chmod +x shnvbr> Navigate to directory with shns/flacs.  Have a lot of fun!
This script will REPLACE your shns/flacs with mp3s.  Therefore, Archive shn/flacs first --  Don't trade mp3s --  Love everone! 

--

#!/bin/bash

## this script converts lossless files to lossy ones
## use with care! - archive shns/flacs!
## have fun!

echo -e '\E[34m\n::shn/flac -> wav -> vbr mp3::(cl)2006 trout fishing in america::'
echo -e '\E[0m'

## from .shn to .wav

if ls *shn &>/dev/null ; then
for shnfile in *.shn ; do
echo -e '\E[35m\n::decoding '$shnfile'::\n'; echo -e '\E[0m'
shorten -x "$shnfile" "$shnfile".wav && rm -f "$shnfile"
done
fi

## rename meaningless '.shn.wav' to '.wav'

for file in *wav ; do
rename .shn.wav .wav "$file"
done

## from .flac to .wav

if ls *flac &>/dev/null ; then
for flacfile in *.flac ; do
echo -e '\E[35m\n::decoding '$flacfile'::'; echo -e '\E[0m'
flac -d "$flacfile" && rm -f "$flacfile"
done
fi

## from .wav to .mp3 (vbr, q=0)

if ls *wav &>/dev/null ; then
for wavfile in *.wav ; do
echo -e '\E[35m\n::converting '$wavfile' to '$wavfile'.mp3::'; echo -e '\E[0m'
lame --preset extreme "$wavfile" "$wavfile.mp3" && rm -f "$wavfile"
done
fi

## rename meaningless 'wav' to meaningful 'vbr'

if ls *wav.mp3 &>/dev/null ; then
for mp3file in *.mp3 ; do
rename wav.mp3 vbr.mp3 "$mp3file" &>/dev/null
done
fi

## a note of finality

if ls *mp3 &>/dev/null ; then
echo -e '\E[34m\n::omnia per nota commutata sunt::' ; echo -e '\E[0m'
else echo -e '\E[34m\n::nulla per nota commutata sunt::' ; echo -e '\E[0m'
fi