Created
February 19, 2014 16:25
-
-
Save tom-a/9095563 to your computer and use it in GitHub Desktop.
mp3のプレイリストを、アルバム順にランダムに並び替える
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
#$Id: reorder.rb,v 1.2 2003/02/17 18:34:10 tom-a Exp tom-a $ | |
# m3uファイルを読み込んで、パス名で1ブロックとしてランダム出力 | |
# albamが同じパス名のファイル群を収納する配列 | |
# listはalbamを収納する配列 | |
$KCODE="sjis" | |
prevpath = "" | |
albam = [] | |
list =[] | |
while gets | |
currentpath = $_[/.*\\/] | |
if prevpath == currentpath then | |
albam += [$_] | |
else | |
list += [albam] | |
albam = [$_] | |
end | |
prevpath = currentpath | |
end | |
list += [albam] | |
while list.size > 0 | |
i = rand(list.size-1) | |
print list[i] | |
list.delete_at(i) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment