正如问题所暗示的,我正在努力将我的脚本压缩为尽可能少的代码行,而不是声明多个if
语句。
目标是在 audacity 中创建一个自动化脚本,以规范化我的音乐库的音频。窗口检测和其他功能都有效,我只是想知道如何将其压缩以使用更少的代码来运行。
提前感谢您的帮助。
#!/bin/bash
media=0
loop=0
cd "/home/satan/Music/.processing/"
while [[ $media -eq 0 ]]
do
if [[ "$media" -gt '0' ]]
then
break
else
cd *
fi
aa=`ls -1 *.aa 2>/dev/null | wc -l`
if [ $aa != 0 ]
then
media=$((aa+media))
echo $aa "aa files found in"
pwd
echo
ls -1
echo
fi
aac=`ls -1 *.aac 2>/dev/null | wc -l`
if [ $aac != 0 ]
then
media=$((aac+media))
echo $aac "aac files found in"
pwd
echo
ls -1
echo
fi
aax=`ls -1 *.aax 2>/dev/null | wc -l`
if [ $aax != 0 ]
then
media=$((aax+media))
echo $aax "aax files found in"
pwd
echo
ls -1
echo
fi
act=`ls -1 *.act 2>/dev/null | wc -l`
if [ $act != 0 ]
then
media=$((act+media))
echo $act "act files found in"
pwd
echo
ls -1
echo
fi
aiff=`ls -1 *.aiff 2>/dev/null | wc -l`
if [ $aiff != 0 ]
then
media=$((aiff+media))
echo $aiff "aiff files found in"
pwd
echo
ls -1
echo
fi
alac=`ls -1 *.alac 2>/dev/null | wc -l`
if [ $alac != 0 ]
then
media=$((alac+media))
echo $alac "alac files found in"
pwd
echo
ls -1
echo
fi
ape=`ls -1 *.ape 2>/dev/null | wc -l`
if [ $ape != 0 ]
then
media=$((ape+media))
echo $ape "ape files found in"
pwd
echo
ls -1
echo
fi
au=`ls -1 *.au 2>/dev/null | wc -l`
if [ $au != 0 ]
then
media=$((au+media))
echo $au "au files found in"
pwd
echo
ls -1
echo
fi
dss=`ls -1 *.dss 2>/dev/null | wc -l`
if [ $dss != 0 ]
then
media=$((dss+media))
echo $dss "dss files found in"
pwd
echo
ls -1
echo
fi
dvf=`ls -1 *.dvf 2>/dev/null | wc -l`
if [ $dvf != 0 ]
then
media=$((dvf+media))
echo $dvf "dvf files found in"
pwd
echo
ls -1
echo
fi
flac=`ls -1 *.flac 2>/dev/null | wc -l`
if [ $flac != 0 ]
then
media=$((flac+media))
echo $flac "flac files found in"
pwd
echo
ls -1
echo
fi
gsm=`ls -1 *.gsm 2>/dev/null | wc -l`
if [ $gsm != 0 ]
then
media=$((gsm+media))
echo $gsm "gsm files found in"
pwd
echo
ls -1
echo
fi
iklax=`ls -1 *.iklax 2>/dev/null | wc -l`
if [ $iklax != 0 ]
then
media=$((iklax+media))
echo $iklax "iklax files found in"
pwd
echo
ls -1
echo
fi
ivs=`ls -1 *.ivs 2>/dev/null | wc -l`
if [ $ivs != 0 ]
then
media=$((ivs+media))
echo $ivs "ivs files found in"
pwd
echo
ls -1
echo
fi
m4a=`ls -1 *.m4a 2>/dev/null | wc -l`
if [ $m4a != 0 ]
then
media=$((m4a+media))
echo $m4a "m4a files found in"
pwd
echo
ls -1
echo
fi
m4b=`ls -1 *.m4b 2>/dev/null | wc -l`
if [ $m4b != 0 ]
then
media=$((m4b+media))
echo $m4b "m4b files found in"
pwd
echo
ls -1
echo
fi
m4p=`ls -1 *.m4p 2>/dev/null | wc -l`
if [ $m4p != 0 ]
then
media=$((m4p+media))
echo $m4p "m4p files found in"
pwd
echo
ls -1
echo
fi
mmf=`ls -1 *.mmf 2>/dev/null | wc -l`
if [ $mmf != 0 ]
then
media=$((mmf+media))
echo $mmf "mmf files found in"
pwd
echo
ls -1
echo
fi
movpkg=`ls -1 *.movpkg 2>/dev/null | wc -l`
if [ $movpkg != 0 ]
then
media=$((movpkg+media))
echo $movpkg "movpkg files found in"
pwd
echo
ls -1
echo
fi
mpc=`ls -1 *.mpc 2>/dev/null | wc -l`
if [ $mpc != 0 ]
then
media=$((mpc+media))
echo $mpc "mpc files found in"
pwd
echo
ls -1
echo
fi
mp3=`ls -1 *.mp3 2>/dev/null | wc -l`
if [ $mp3 != 0 ]
then
media=$((mp3+media))
echo $mp3 "mp3 files found in"
pwd
echo
ls -1
echo
fi
msv=`ls -1 *.msv 2>/dev/null | wc -l`
if [ $msv != 0 ]
then
media=$((msv+media))
echo $msv "act files found in"
pwd
echo
ls -1
echo
fi
nmf=`ls -1 *.nmf 2>/dev/null | wc -l`
if [ $nmf != 0 ]
then
media=$((nmf+media))
echo $nmf "nmf files found in"
pwd
echo
ls -1
echo
fi
ogg=`ls -1 *.ogg 2>/dev/null | wc -l`
if [ $ogg != 0 ]
then
media=$((ogg+media))
echo $ogg "ogg files found in"
pwd
echo
ls -1
echo
fi
oga=`ls -1 *.oga 2>/dev/null | wc -l`
if [ $oga != 0 ]
then
media=$((oga+media))
echo $oga "oga files found in"
pwd
echo
ls -1
echo
fi
mogg=`ls -1 *.mogg 2>/dev/null | wc -l`
if [ $mogg != 0 ]
then
media=$((mogg+media))
echo $mogg "mogg files found in"
pwd
echo
ls -1
echo
fi
opus=`ls -1 *.opus 2>/dev/null | wc -l`
if [ $opus != 0 ]
then
media=$((opus+media))
echo $opus "opus files found in"
pwd
echo
ls -1
echo
fi
ra=`ls -1 *.ra 2>/dev/null | wc -l`
if [ $ra != 0 ]
then
media=$((ra+media))
echo $ra "ra files found in"
pwd
echo
ls -1
echo
fi
rm=`ls -1 *.rm 2>/dev/null | wc -l`
if [ $rm != 0 ]
then
media=$((rm+media))
echo $rm "rm files found in"
pwd
echo
ls -1
echo
fi
raw=`ls -1 *.raw 2>/dev/null | wc -l`
if [ $raw != 0 ]
then
media=$((raw+media))
echo $raw "raw files found in"
pwd
echo
ls -1
echo
fi
rt64=`ls -1 *.rt64 2>/dev/null | wc -l`
if [ $rt64 != 0 ]
then
media=$((rt64+media))
echo $rt64 "rt64 files found in"
pwd
echo
ls -1
echo
fi
sln=`ls -1 *.sln 2>/dev/null | wc -l`
if [ $sln != 0 ]
then
media=$((sln+media))
echo $sln "sln files found in"
pwd
echo
ls -1
echo
fi
tta=`ls -1 *.tta 2>/dev/null | wc -l`
if [ $tta != 0 ]
then
media=$((tta+media))
echo $tta "tta files found in"
pwd
echo
ls -1
echo
fi
voc=`ls -1 *.voc 2>/dev/null | wc -l`
if [ $voc != 0 ]
then
media=$((voc+media))
echo $voc "voc files found in"
pwd
echo
ls -1
echo
fi
vox=`ls -1 *.vox 2>/dev/null | wc -l`
if [ $vox != 0 ]
then
media=$((vox+media))
echo $vox "vox files found in"
pwd
echo
ls -1
echo
fi
wav=`ls -1 *.wav 2>/dev/null | wc -l`
if [ $wav != 0 ]
then
media=$((wav+media))
echo $wav "wav files found in"
pwd
echo
ls -1
echo
fi
wma=`ls -1 *.wma 2>/dev/null | wc -l`
if [ $wma != 0 ]
then
media=$((wma+media))
echo $wma "wma files found in"
pwd
echo
ls -1
echo
fi
webm=`ls -1 *.webm 2>/dev/null | wc -l`
if [ $webm != 0 ]
then
media=$((webm+media))
echo $webm "webm files found in"
pwd
echo
ls -1
echo
fi
cda=`ls -1 *.cda 2>/dev/null | wc -l`
if [ $cda != 0 ]
then
media=$((cda+media))
echo $cda "cda files found in"
pwd
echo
ls -1
echo
fi
threegp=`ls -1 *.3gp 2>/dev/null | wc -l`
if [ $threegp != 0 ]
then
media=$((threegp+media))
echo $threegp "3gp files found in"
pwd
echo
ls -1
echo
fi
eightsvx=`ls -1 *.8svx 2>/dev/null | wc -l`
if [ $eightsvx != 0 ]
then
media=$((eightsvx+media))
echo $eightsvx "8svx files found in"
pwd
echo
ls -1
echo
fi
done
nohup pcmanfm >/dev/null 2>&1 &