### copy to other folder. It works on parallel, you can
### use it in a cluster with Parameter -S.
-work="$(pwd)/work.$$" # temporary working directory
-scriptpath="/usr/bin" # path to flactomp3v2 and notify.sh script
-musicpath="/tmp/musikpath" # flac collection directory
+WORK="$(pwd)/WORK.$$" # temporary working directory
+SCRIPTPATH="/usr/bin" # path to flactomp3v2 and notify.sh script
+MUSICPATH="/tmp/musikpath" # flac collection directory
# check exist config and scripts
-# .albentohandy.conf: set scriptpath and musicpath
+# .albentohandy.conf: set SCRIPTPATH and MUISCPATH
if [ -f $HOME/.albentohandy.conf ]; then
source $HOME/.albentohandy.conf
else
exit 1
fi
# flactomp3v2: convert flac's to mp3
-if [ ! -f $scriptpath/flactomp3v2 ]; then
- printf "\nERROR\nflactomp3v2 do not found in %s\n" $scriptpath
+if [ ! -f $SCRIPTPATH/flactomp3v2 ]; then
+ printf "\nERROR\nflactomp3v2 do not found in %s\n" $SCRIPTPATH
exit 1
fi
# notify.sh: functions send email
-if [ ! -f $scriptpath/notify.sh ]; then
- printf "\nERROR\nnotify.sh do not found in %s\n" $scriptpath
+if [ ! -f $SCRIPTPATH/notify.sh ]; then
+ printf "\nERROR\nnotify.sh do not found in %s\n" $SCRIPTPATH
exit 1
else
- source $scriptpath/notify.sh
+ source $SCRIPTPATH/notify.sh
fi
# set defaults
removework=true
;;
"w")
- work="$OPTARG"
+ WORK="$OPTARG"
;;
"z")
mkzip=true
fi
# create working directory
-if [ ! -d $work ]; then
- mkdir $work
+if [ ! -d $WORK ]; then
+ mkdir $WORK
fi
openMail
addInfo "<p>Foldende Alben wurden ausgewählt:</p>"
addInfo "<p>$(cat "$albumlist" | sed 's/$/<br>/')</p>"
# make symlinks of original flac's in working directory
-printf "\nPhase %02d of %02d: create symlinks of flac's to working directory %s\n" $((curphase++)) $phase "$work"
+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 --recursive --symbolic-link $musicpath/$i $work/
+ cp --recursive --symbolic-link $MUISCPATH/$i $WORK/
done
addInfo "<p>"
# 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 $BASEFILE --will-cite --ungroup --eta --progress --sshlogin $parallelopts $scriptpath/flactomp3v2 {}
+find $WORK -name '*.flac' | sort | parallel $BASEFILE --will-cite --ungroup --eta --progress --sshlogin $parallelopts $SCRIPTPATH/flactomp3v2 {}
currentDate
addInfo "flac -> mp3 finished</p>"
# 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
+find $WORK -name '*.flac' | sort | xargs rm
+find $WORK -name 'cover*' | sort | xargs rm
# create sha256sum in working directory
if [ $checksum == true ]; then
currentDate
addInfo "create sha256sum is start<br>"
printf "Phase %02d of %02d: create sha256sum\n\n" $((curphase++)) $phase
- find $work -name '*.mp3' | sort | xargs sha256sum | sed "s=$work/==" >> $work/sha256sum
+ find $WORK -name '*.mp3' | sort | xargs sha256sum | sed "s=$WORK/==" >> $WORK/sha256sum
currentDate
addInfo "sha256sum is created</p>"
fi
currentDate
addInfo "create $zipname start<br>"
curpath=$(pwd)
- cd $work
+ cd $WORK
7z a -bd -mmt=off -mm=Copy $curpath/$zipname .
cd $curpath
printf "\n"
# 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
+ printf "Phase %02d of %02d: copy %s/ to destination %s\n\n" $((curphase++)) $phase $WORK $dest
addInfo "<p>"
currentDate
- addInfo "copy from $work to $dest start<br>"
+ addInfo "copy from $WORK to $dest start<br>"
mkdir --parents $dest
- cp --recursive $work/* $dest
+ cp --recursive $WORK/* $dest
currentDate
- addInfo "copy from $work to $dest finished</p>"
+ addInfo "copy from $WORK to $dest finished</p>"
fi
# delete the working directory
if ( [ $mkzip == true ] || [ $cptodest == true ] ) && [ $removework == true ]; then
printf "cleanup working directory\n\n"
- rm --recursive $work
+ rm --recursive $WORK
fi
addInfo "<p>"