From: Bastian Dehn Date: Mon, 11 Jul 2016 19:43:43 +0000 (+0200) Subject: add: comments in albentohandy.sh X-Git-Tag: v1.0.0^2~137 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=ed85a0dedd176a945b535b86db483dd67507c3d3;p=albentohandy.git add: comments in albentohandy.sh --- diff --git a/albentohandy.sh b/albentohandy.sh index 0b3add1..69b14f7 100755 --- a/albentohandy.sh +++ b/albentohandy.sh @@ -1,11 +1,14 @@ #!/bin/bash -# work is a directory do symlinked original and convert +# working directory work="$(pwd)/work.$$" -# scriptpath is the path to flactomp3v2.sh script +# path to flactomp3v2.sh script scriptpath="/tmp/scripts" -# musicpath is collection directory +# collection directory musicpath="/tmp/musikpath" + +# Check exist config and script is exists +# config file can set scriptpath and musicpath if [ -f $HOME/.albumtohandy.conf ] then source $HOME/.albumtohandy.conf @@ -18,6 +21,8 @@ then printf "\nERROR\nflactomp3v2.sh do not found in %s\n" $scriptpath exit 1 fi + +# set defaults albumlist="albumlist" parallelopts=":" curphase=1 @@ -27,6 +32,7 @@ mkzip=false removework=false cptodest=false +# read parameters while getopts ":ci:m:S::rz:" optname do case "$optname" in @@ -56,37 +62,44 @@ do esac done +# check albumlist is set if [ ! -f "$albumlist" ] then printf "\nalbumlist does not exists\n\n" exit fi -printf "\nPhase %02d of %02d: create symlinks of flac's to working directory %s\n" $((curphase++)) $phase "$work" - +# create working directory if [ ! -d $work ] then mkdir $work fi # make symlinks of original flac's +printf "\nPhase %02d of %02d: create symlinks of flac's to working directory %s\n" $((curphase++)) $phase "$work" for i in $(cat "$albumlist") do cp -rs $musicpath/$i $work/ done +# convert flac to mp3 +# it is the longest phase printf "\nPhase %02d of %02d: flac -> mp3\n" $((curphase++)) $phase find $work -name '*.flac' | sort | parallel --eta --progress --noswap -S $parallelopts $scriptpath/flactomp3v2.sh {} +# removing flac and cover.jpg printf "\nPhase %02d of %02d: remove flac's and cover's\n\n" $((curphase++)) $phase find $work -name '*.flac' | sort | xargs rm find $work -name 'cover*' | sort | xargs rm +# create sha256sum in working directory if [ $checksum == true ] then printf "Phase %02d of %02d: create sha256sum\n\n" $((curphase++)) $phase find $work -name '*.mp3' | sort | xargs sha256sum | sed "s=$work/==" >> $work/sha256sum fi + +# make zipfile in the current path if [ $mkzip == true ] then printf "Phase %02d of %02d: create %s\n" $((curphase++)) $phase $zipname @@ -96,6 +109,8 @@ then cd $curpath printf "\n" fi + +# copy work directory to destination folder if [ $cptodest == true ] then printf "Phase %02d of %02d: copy %s/ to destination %s\n\n" $((curphase++)) $phase $work $dest @@ -105,6 +120,8 @@ then fi cp -r $work/* $dest fi + +# delete the working directory if ( [ $mkzip == true ] || [ $cptodest == true ] ) && [ $removework == true ] then printf "cleanup working directory\n\n"