建议如何在继续脚本之前检查是否存在音频CD-ROM

时间:2015-02-16 15:14:52

标签: bash while-loop

我找到了一个很好的解决方案来检查是否存在音频CD。它适用于While循环,我喜欢在音频剪辑完成并且光盘弹出后结束。

while true; do
    sleep 10
    cdparanoia -Q 2>&1 | grep 'audio only'
    RET=$?
    if [ $RET = "0" ] ; then
        abcde -c ~/Music/abcde.conf -o flac,mp3,ogg -p -x
    fi
done

1 个答案:

答案 0 :(得分:0)

我相信我找到了我的愿望的解决方案,特此是我的代码

#!/bin/bash

echo "voer componist in"
read componist
echo ingevoerde "$componist"

echo "voer het aantal CD's in"
read aantaldiscs
echo aantal discs $aantaldiscs

mkdir ~/Music/"$componist"
for a in $(seq -f %02g 01 $aantaldiscs);
do
mkdir ~/Music/"$componist"/$a
echo "OUTPUTDIR='~/Music/"$componist"/$a'" > ~/Music/abcde.conf
echo "OUTPUTFORMAT='\${TRACKNUM}.\${TRACKFILE}'" >> ~/Music/abcde.conf
echo "LAMEOPTS='-V 0'" >> ~/Music/abcde.conf
echo "FLACOPTS='-f --verify --best'" >> ~/Music/abcde.conf
echo "OGGENCOPTS='-q 8'" >> ~/Music/abcde.conf
echo "MAXPROCS=2" >> ~/Music/abcde.conf

echo "mungefilename ()" >> ~/Music/abcde.conf
echo "{" >> ~/Music/abcde.conf
echo "echo "$@" | sed s,:,\ -,g | tr / _ | tr -d \’\"\?\[:cntrl:\]" >> ~/Music/abcde.conf
echo "}" >> ~/Music/abcde.conf

    while true; do
        sleep 10
        cdparanoia -Q 2>&1 | grep 'audio only'
        RET=$?
        if [ $RET = "0" ] ; then
            abcde -c ~/Music/abcde.conf -o flac,mp3,ogg -p -x
            break
        fi
    done
done