[net.music.gdead] two scripts for manipulating playlists

cliff@unmvax.UUCP (04/23/85)

I couldn't get this letter to osiris!phil.  He sent me a run-down on
the number of times each song was played.  I appreciate the effort,
but I've been doing this for a while.  Before I get bombarded from
all sides, I thought some people might like the scripts that I tried
to send to him (I haven't and don't want to figure out ARPA).  Here
is the letter I tried to get to Phil.

Thanks for the info.
I have a few nice awk programs to figure out such things.
One thing to watch for is when they do "Playin'" twice on
one night; it should only be counted once.  I use this
csh script (fix) to get around that problem:

#! /bin/csh -f
if ($#argv == 0) then
    set arg = ""
else
    set arg = "$*"
endif
awk '\
$0  ~ /[0-9]/	{ c = $0 } \
$0 !~ /^[ 0-9a-z]/	{ if (NF > 0 && s[$0] != c) { \
		      print $0 \
		      s[$0] = c \
		  } \
		}' $arg

I also have another useful script called merge:

#! /bin/csh -f
if ($#argv == 1) then
    set arg = $argv[1]
else
    set arg = ""
endif
awk '\
	{ if (old == $0)\
	      count++\
	  else {\
	      if (count != 0)\
		  print count, old\
	      old = $0\
	      count = 1\
	  }\
	}\
END	{ print count, old }' $arg

A typical sequence is:

% fix play* | sort | merge | sort -n

These scripts come in handy when I am curious about what mix of songs
were played when.  I will be writing a program that looks at a set
of dates and decides the most number of concerts from those dates
that contain no duplicates...funny thing is, it is more or less an
assignment in our heuristics class.

				--Cliff