0

I am trying to write a bash script to create some playlists of music. The part that has me stuck is the while loop for read line. I figure I am over thinking this so I turned to stackoverflow for assistance.

# 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
sgibb
  • 25,396
  • 3
  • 68
  • 74
Greg Kuhn
  • 35
  • 5
  • 2
    Perhaps it's just me, but I don't see your code generating any track list that the innermost loop could read. – Ansgar Wiechers Jul 07 '13 at 12:29
  • 2
    What is `read line` supposed to be reading from? Also, what's `xxx` in `z=$[$z + xxx]`? – Gordon Davisson Jul 07 '13 at 14:16
  • What's the question? Couple of notes, though: `$[` is deprecated. `echo -e` doesn't mean what you think it does (or at least the `-e` is pointless in both instances.) `echo Iteration $((i++))` will work fine. The division could be written `secs=$(metaflac --show-total-samples --show-sample-rate "$line" | dc - <(echo /p))`, although that might be considered obfuscated. – rici Jul 07 '13 at 20:12
  • I am not sure what my original question was but I got working with some tinkering. – Greg Kuhn Sep 15 '13 at 10:21

0 Answers0