09 December 2010

Some shell scripts

All shell scripts on this page work on Linux. They should also work on BSD.

For Windows, at a minimum, the "$" needs to be changed to "%", Other changes may be needed. The appropriate utility will also need to be installed.

I do not know what changes are needed for Mac OS X.


I recently downloaded the audio version of the World English Bible from http://www.ebible.org/web/.

File names are Book name and than Chapter number. For example: Genesis_01.mp3.
Each book unzips into its own directory.



I used the following shell script to unzip the files.

for f in *; do unzip -j $f; echo $f ; done

The "-j" flag tells unzip to put everything in the same directory.


That left me with the following mess:


Mark_05.mp3 Jeremiah_26.mp3 EZEKIEL_38.mp3 2TIM4.mp3 1Chronicles_23.mp3
Psalm_006.mp3 Mark_04.mp3 Jeremiah_27.mp3 EZEKIEL_37.mp3 2Samuel_23.mp3 1Chronicles_24.mp3
Psalm_001.mp3 Mark_02.mp3 Jeremiah_25.mp3 EZEKIEL_36.mp3 2Samuel_24.mp3 1Chronicles_21.mp3
Psalm_002.mp3 Mark_03.mp3 Jeremiah_23.mp3 EZEKIEL_35.mp3 2Samuel_22.mp3 1Chronicles_22.mp3
Psalm_148.mp3 Mark_01.mp3 Jeremiah_24.mp3 EZEKIEL_34.mp3 2Samuel_20.mp3 1Chronicles_17.mp3
Psalm_149.mp3 MALACHI_01.mp3 Jeremiah_22.mp3 EZEKIEL_33.mp3 2Samuel_21.mp3 1Chronicles_18.mp3
Psalm_150.mp3 MALACHI_02.mp3 Jeremiah_19.mp3 EZEKIEL_32.mp3 2Samuel_19.mp3 1Chronicles_19.mp3
Psalm_146.mp3 MALACHI_03.mp3
Mark_05.mp3 Jeremiah_26.mp3 EZEKIEL_38.mp3 2TIM4.mp3 1Chronicles_23.mp3
Psalm_006.mp3 Mark_04.mp3 Jeremiah_27.mp3 EZEKIEL_37.mp3 2Samuel_23.mp3 1Chronicles_24.mp3
Psalm_001.mp3 Mark_02.mp3 Jeremiah_25.mp3 EZEKIEL_36.mp3 2Samuel_24.mp3 1Chronicles_21.mp3
Psalm_002.mp3 Mark_03.mp3 Jeremiah_23.mp3 EZEKIEL_35.mp3 2Samuel_22.mp3 1Chronicles_22.mp3
Psalm_148.mp3 Mark_01.mp3 Jeremiah_24.mp3 EZEKIEL_34.mp3 2Samuel_20.mp3 1Chronicles_17.mp3
Psalm_149.mp3 MALACHI_01.mp3 Jeremiah_22.mp3 EZEKIEL_33.mp3 2Samuel_21.mp3 1Chronicles_18.mp3
Psalm_150.mp3 MALACHI_02.mp3 Jeremiah_19.mp3 EZEKIEL_32.mp3 2Samuel_19.mp3 1Chronicles_19.mp3
Psalm_146.mp3 MALACHI_03.mp3

I then used a script to convert everything to lower case. That script can be found at
http://biblestuff.pastebin.com/a7TZU8Ti.
I wrote a shell script to convert the mp3 files to wma format.

#!/bin/bash
for f in *.mp3; do ffmpeg -i "$f" -acodec wmav2 -ab 256k "${f%.mp3}.wma"; done

That script can also be found at http://biblestuff.pastebin.com/fpHhJGB0