#!/bin/sh
# ape, flac, wv c cue flac. .
# ! cuetools,shntool,mac. , .
# , - CUE- .
clear #
######################################################################################################################
_chk_pkg_ape () # / APE,
{
N="" # N
P1=cuetag
P2=shnsplit
P3=flac
P4=mac
which $P1 >/dev/null
if [ "$?" -ne 0 ]
then
N="cuetools"
fi
which $P2 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N shntool"
fi
which $P3 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N $P3"
fi
which $P4 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N $P4"
fi
}
######################################################################################################################
_chk_pkg_flac () # / FLAC,
{
N="" # N
P1=cuetag
P2=shnsplit
P3=flac
which $P1 >/dev/null
if [ "$?" -ne 0 ]
then
N="cuetools"
fi
which $P2 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N shntool"
fi
which $P3 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N $P3"
fi
}
######################################################################################################################
_chk_pkg_wv () # / WavPack,
{
N="" # N
P1=cuetag
P2=shnsplit
P3=flac
P4=wavpack
which $P1 >/dev/null
if [ "$?" -ne 0 ]
then
N="cuetools"
fi
which $P2 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N shntool"
fi
which $P3 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N $P3"
fi
which $P4 >/dev/null
if [ "$?" -ne 0 ]
then
N="$N $P4"
fi
}
######################################################################################################################
_pkg_inst () # ,
{
[ "$N" ]
if [ $? -eq 0 ]
then
echo " : $N. ? (y/n)"
read reply1
case "$reply1" in
"Y" | "y" )
sudo apt-get install $N
;;
* )
echo " , , !"
exit 1
;;
esac
fi
}
#####################################################################################################################
_conv_ape () # APE
{
mv *.ape qiwitemp.ape # ape
cuebreakpoints "myutf8.cue" | shnsplit -o flac "qiwitemp.ape" #
cuetag "myutf8.cue" split-track*.flac #
mv qiwitemp.ape qiwitemp.ape~ # ape
}
######################################################################################################################
_conv_flac () # FLAC
{
mv *.flac qiwitemp.flac # flac
cuebreakpoints "myutf8.cue" | shnsplit -o flac "qiwitemp.flac" #
cuetag "myutf8.cue" split-track*.flac #
mv qiwitemp.flac qiwitemp.flac~ # flac
}
######################################################################################################################
_conv_wv () # WavPack ( , .. )
{
mv *.wv qiwitemp.wv # WV
wvunpack -cc qiwitemp.wv # WV WAV CUE
mv *.wav qiwitemp.wav # WAV
mv qiwitemp.wv qiwitemp.wv~ # WV,
flac qiwitemp.wav # WAV FLAC
mv *.cue qiwitemp.cue # cue
iconv --from-code=CP1251 --to-code=UTF-8 --output=myutf8.cue "qiwitemp.cue" && rm qiwitemp.cue # CP1251 UTF-8,
echo " " >>myutf8.cue # ( ) , cuebreakpoints
_conv_flac # FLAC
}
######################################################################################################################
_chk_files () #
{
Q_APE=$(ls | tr 'AZ' 'az' | grep '.ape' | wc -l) # c ape
Q_FLAC=$(ls | tr 'AZ' 'az' | grep '.flac' | wc -l) # c flac
Q_WV=$(ls | tr 'AZ' 'az' | grep '.wv' | wc -l) # c wv
Q_CUE=$(ls | tr 'AZ' 'az' | grep '.cue' | wc -l) # c cue
if [ "$Q_CUE" -ne 1 ] # cue
then
if [ "$Q_WV" -ne 1 ]
then # WV, CUE
echo ", CUE , : "$Q_CUE". "
exit 1
fi
else
rename 'y/AZ/az/' * #
mv *.cue qiwitemp.cue # cue
iconv --from-code=CP1251 --to-code=UTF-8 --output=myutf8.cue "qiwitemp.cue" && rm qiwitemp.cue # CP1251 UTF-8,
echo " " >>myutf8.cue # ( ) , cuebreakpoints
fi
Q_ALL=`expr $Q_APE + $Q_FLAC + $Q_WV` # -
if [ "$Q_ALL" -ne 1 ]
then
echo "!!! , - (APE, FLAC, WavPack), : "$Q_ALL". "
exit 1
fi
if [ "$Q_APE" -ne 1 ] # , - , ,
then
if [ "$Q_FLAC" -ne 1 ]
then
_chk_pkg_wv
_pkg_inst
_conv_wv
else
_chk_pkg_flac
_pkg_inst
_conv_flac
fi
else
_chk_pkg_ape
_pkg_inst
_conv_ape
fi
}
######################################################################################################################
_over () #
{
mkdir CONVERTED && mv *.flac ./CONVERTED # -
cd ./CONVERTED
which easytag >/dev/null
if [ "$?" -ne 0 ]
then
echo " , "easytag" . ."
exit 0
else
easytag "$(pwd)"
exit 0
fi
}
#*********************************************************************************************************************#
#*********************************************************************************************************************#
_chk_files
_over
Source: https://habr.com/ru/post/87452/
All Articles