#!/bin/sh # # Create the index file in all mp3 directories # # $Id: mkidx,v 1.2 2002/05/26 17:50:15 dds Exp $ # # (C) Copyright 2000-2002 Diomidis Spinellis # # Permission to use, copy, and distribute this software and its # documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appear in all copies and that # both that copyright notice and this permission notice appear in # supporting documentation. # # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # find /vol/music -name '*.mp3' -print | sed 's,/[^/]*$,,' | sort -u | while read dir do ( cd "$dir" if ! [ -f index.txt ] then CDNUM=`cat /vol/db/cdnum` CDNUM=`expr $CDNUM + 1` echo $CDNUM >/vol/db/cdnum echo "# Index" >index.txt echo "DN $CDNUM" >>index.txt for i in *.mp3 do TRACKNUM=`cat /vol/db/tracknum` TRACKNUM=`expr $TRACKNUM + 1` echo $TRACKNUM >/vol/db/tracknum echo "TN $TRACKNUM$i" >>index.txt done fi ) done