0

我正在尝试编写一个 bash 脚本来创建一些音乐播放列表。让我卡住的部分是读取行的 while 循环。我想我想太多了,所以我转向 stackoverflow 寻求帮助。

# The first while loop is how many playlists I want to create
i=1
while [ $i -le $plist ]
do
    echo -e "iteration $i"
    i=$[$i + 1]

    z=0
    # This while loop is for the length of time I want the playlist to be
    while [ $z -le $TOTAL ]
    do
       echo -e "Count $z"
       z=$[$z + xxx]
       # This while loop is for reading the track list previously generated.
       # It would read the line, calculate the track length, 
       # add to $z, cp the track to a folder
       while read line
       do
            secs=$(metaflac --show-total-samples --show-sample-rate "$line" | tr '\n' ' '
            | awk '{print $1/$2}' -)
            z=$[$z + $secs]
            cp $line to destination folder 
       done
    done
done
4

0 回答 0