|
#!/bin/bash |
|
#This program used for resizing and batch wave -- mp3 encoding |
|
#Please make sure you have |
|
#* lame |
|
#* sips |
|
#* mp3splt |
|
#installed before run it |
|
##Author Andrew Shatnyy |
|
|
|
year=$(date +"%Y") #today's year tag for ID3v2 |
|
comment="Property of nuwax records ${year} (c)" #comment tag for ID3v2 |
|
|
|
echo |
|
echo "***********************************************" |
|
echo "* Nuwaxrecords encoder *" |
|
echo "* ${comment} *" |
|
echo "* Author: Andrew Shatnyy *" |
|
echo "***********************************************" |
|
echo |
|
|
|
function getTotal { |
|
# counts total tracks in forlder |
|
t=1 #counter total for track numbers |
|
for c in *.wav; do |
|
tt=$((t++)) |
|
done |
|
} |
|
|
|
#fetching release namebased on working derictory and its naming format: |
|
# [Catalogue ##] Artist Name - Album name |
|
function getReleasename { |
|
#assiging script absolute path to variable |
|
# basefolder=$(dirname "$0"|tr " " "\ "|tr "(" "\("|tr ")" "\)") |
|
#echo "basefolder is: "${basefolder} |
|
# relesename=$(echo ${basefolder} |cut -d- -f2| cut -c2-) |
|
# catalogue=$(echo ${basefolder} |cut -d"[" -f2 |cut -d"]" -f1) |
|
|
|
relesename=$(echo basename `pwd` |cut -d- -f2| cut -c2-) |
|
catalogue=$(echo basename `pwd` |cut -d"[" -f2 |cut -d"]" -f1) |
|
|
|
#catalogue=${catalogue} |
|
#cd script to workfolder |
|
cd "${basefolder}" |
|
#pwd |
|
echo |
|
echo "***********************************************" |
|
echo "Release name is: ${relesename}" |
|
echo "***********************************************" |
|
echo |
|
} |
|
|
|
function resize { |
|
#resizing a file |
|
sips -z 300 300 "${catalogue}.jpg" --out "${catalogue}_300.jpg" |
|
artwork="${catalogue}_300.jpg" |
|
} |
|
|
|
function encode { |
|
#encoding process |
|
echo |
|
echo "Starting encoding ${filename}" |
|
echo "***********************************************" |
|
echo |
|
lame "$file" "${encodedFile}" -c -b 320 --tg "house" --tt "${title}" --ta "${artist}" --tn "${ct}/${tt}" --tl "${relesename}" --ty "${year}" --ti "${artwork}" --tc "${comment}"--add-id3v2 |
|
} |
|
|
|
function process { |
|
#main encoding loop |
|
n=1 #counter for track numbers |
|
for file in *.wav; do |
|
#file=$(echo $file|cut -d] -f2|cut -d/ -f2) |
|
#echo "Working on file "${file} |
|
ct=$((n++)) |
|
artist=$(echo $file |cut -d- -f1 | cut -d" " -f2) |
|
title=$(echo $file |cut -d- -f2|cut -d. -f1|cut -c2-) |
|
filename=$(echo $file |cut -d\. -f1|tr " " "_") |
|
encodedFile="./${fold}/${filename}.mp3" |
|
echo "***********************************************" |
|
echo "* Track info " |
|
echo "* Artist: "${artist} |
|
echo "* Title: "${title} |
|
echo "* Combined filename: ${filename}" |
|
echo "***********************************************" |
|
encode |
|
done |
|
echo "***********************************************" |
|
echo "*encoding has finished <<<<<<<<<<<<<<<<<<<<<<<*" |
|
echo "***********************************************" |
|
} |
|
|
|
function makeFolder () { |
|
#creates folder for encoded mp3s |
|
fold="320" |
|
mkdir ${fold} |
|
} |
|
function chopMp3 { |
|
echo |
|
echo "***********************************************" |
|
echo "Chopping file to a sapmples 2 min long *" |
|
echo "***********************************************" |
|
echo |
|
#mp3split will create 320chops folder with output files in it |
|
for mp3 in ./320/*.mp3 ;do |
|
mp3splt -d 320chops ${mp3} 01.00 03.00 |
|
done |
|
} |
|
|
|
function check () { |
|
#checking if files are on place |
|
if [ -e ./${catalogue}.jpg ];then { |
|
echo "***********************************************" |
|
echo "* Artwork was found *" |
|
echo "* *" |
|
# Something wrong with the if statement |
|
# if [ -e ./*.wav ];then { |
|
echo "* Wave files were found *" |
|
echo "***********************************************" |
|
getTotal |
|
resize |
|
makeFolder |
|
process |
|
chopMp3 |
|
# } else { |
|
# echo "Wave files are missing there's nothing to encode" |
|
# } |
|
# fi |
|
|
|
} else { |
|
echo "Missing artwork sorry..." |
|
} |
|
fi |
|
} |
|
getReleasename |
|
check |