From owner-freebsd-questions Sun Nov 25 18:47:24 2001 Delivered-To: freebsd-questions@freebsd.org Received: from maynard.mail.mindspring.net (maynard.mail.mindspring.net [207.69.200.243]) by hub.freebsd.org (Postfix) with ESMTP id 4475F37B417 for ; Sun, 25 Nov 2001 18:47:15 -0800 (PST) Received: from user-38ldiv0.dsl.mindspring.com ([209.86.203.224] helo=Main) by maynard.mail.mindspring.net with smtp (Exim 3.33 #1) id 168Bna-0007CG-00 for freebsd-questions@freebsd.org; Sun, 25 Nov 2001 21:47:11 -0500 Message-ID: <001801c17624$85c958f0$0300a8c0@jayyness.com> From: "Totally Jayyness" To: Subject: Scripting Problems please help Date: Sun, 25 Nov 2001 19:46:17 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0015_01C175E9.D905A4A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C175E9.D905A4A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sorry to bother you but I am going crazy... I am trying to write a = simple script to traverse directories and create playlist files in those = directories. I have tried several things but keep getting errors. I am = obviously having issues with the spaces inside the directory names (see = below for scripts I have triedand errors I am getting). Any help you = guys/gals could offer would be greatly appreciated!!!!!! (Oh, please = reply directly as I am not signed up for the mailing list, probably = would be a good idea to do that though.) OK, I have mp3 files n several directories. Here is a sample of = directories. /usr/test /usr/test/W /usr/test/W/Wall of Voodoo /usr/test/W/Wall of Voodoo/Dark Continent /usr/test/W/Wall of Voodoo/WoV Live /usr/test/W/Weatherman, The /usr/test/W/Weatherman, The/Global 851 /usr/test/W/When in Rome /usr/test/W/White Town /usr/test/W/Wil Smith What I woudl like to do is have a script search each of the directories = for mp3 files and dump that output into a .m3u (playlist file) in it. = for example.. /usr/test/test.m3u /usr/test/W/W.m3u /usr/test/W/Wall of Voodoo/Wall of Voodoo.m3u /usr/test/W/Wall of Voodoo/Dark Continent/Dark Continent.m3u /usr/test/W/Wall of Voodoo/WoV Live/WoV Live.m3u /usr/test/W/Weatherman, The/Weatheran, The.m3u /usr/test/W/Weatherman, The/Global 851/Global 851.m3u /usr/test/W/When in Rome/When in Rome.m3u /usr/test/W/White Town/White Town.m3u /usr/test/W/Wil Smith/Wil Smith.m3u It is ok for parent directories to include mp3s from subdirectories... = so Weatherman, The.m3u would also include the mp3s in it's subdirectory. With help, I have been able to figure out how to get a list of the = subdirectories, wrap the subdirectories in qoutes but after that is = where it all falls apart. My script seems to disregard the qoutes I put = in there and sees the spaces and then fails miserably. I haven't been able to get specifically named m3u files, but putting a = songs.m3u file in each directory will work just as good. I have tried 2 = scripts so far. One that wraps the directory in qoutes=20 "/usr/test/W/Weatherman, The/Global 851/" and one that builds the directory like Unix does when you tab out the = directory: /usr/test/W/Weatherman,\ The/Global\ 851/ SCRIPT 1 #!/bin/sh # # Catalog MP3 files on a directory basis # MP3_ROOT=3D"/usr/test" # Find Directories under /usr/test then wrap entire directory in qoutes = to encompass spaces for mp3_dir in `find $MP3_ROOT -type d -print | sed -e 's/^/\"/' -e = 's/$/\"/'` ; do # Find mp3 files in individual directories, clean them up for = playlist, dump to m3u file in that directory find $mp3_dir -iname '*.mp3' # | sed -e = 's;/usr/test;http://12.159.64.5;' -e 's/ /%20/g' > $mp3_dir/songs.m3u done When I run this script, though, this is what I get. -snip- root:/usr/test>./parse find: ./parse: cannot create "/usr/test"/songs.m3u: directory = nonexistent "/usr/test": No such file or directory find: ./parse: cannot create "/usr/test/W"/songs.m3u: directory = nonexistent "/usr/test/W": No such file or directory find: ./parse: cannot create "/usr/test/W/Wall/songs.m3u: directory = nonexistent "/usr/test/W/Wall: No such file or directory -snip SCRIPT 2 #!/bin/sh # # Catalog MP3 files on a directory basis # MP3_ROOT=3D"/usr/test" for mp3_dir in `find $MP3_ROOT -type d -print | sed -e 's/ /\\ /'` ; do find $mp3_dir -iname "*.mp3" | sed -e = 's;/usr/test;http://12.159.64.5;' -e 's/ /%20/g' > $mp3_dir/songs.m3u done And when I run this script -snip- find: ./parse: cannot create /usr/test/W/Wall/songs.m3u: directory = nonexistent /usr/test/W/Wall: No such file or directory find: ./parse: cannot create of/songs.m3u: directory nonexistent of: No such file or directory find: ./parse: cannot create Voodoo/songs.m3u: directory nonexistent Voodoo: No such file or directory -snip- ------=_NextPart_000_0015_01C175E9.D905A4A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Sorry to bother you but I am going = crazy... I am=20 trying to write a simple script to traverse directories and create = playlist=20 files in those directories.  I have tried several things but keep = getting=20 errors.  I am obviously having issues with the spaces inside the = directory=20 names (see below for scripts I have triedand errors I am getting).  = Any=20 help you guys/gals could offer would be greatly appreciated!!!!!!  = (Oh,=20 please reply directly as I am not signed up for the mailing list, = probably would=20 be a good idea to do that though.)
 
OK, I have mp3 files n several = directories. =20 Here is a sample of directories.
 
/usr/test
/usr/test/W
/usr/test/W/Wall of=20 Voodoo
/usr/test/W/Wall of Voodoo/Dark Continent
/usr/test/W/Wall = of=20 Voodoo/WoV Live
/usr/test/W/Weatherman, = The
/usr/test/W/Weatherman,=20 The/Global 851
/usr/test/W/When in Rome
/usr/test/W/White=20 Town
/usr/test/W/Wil Smith
 
What I woudl like to do is have a = script search=20 each of the directories for mp3 files and dump that output into a = .m3u=20 (playlist file) in it.  for example..
 
/usr/test/test.m3u
/usr/test/W/W.m3u
/usr/test/W/Wall of=20 Voodoo/Wall of Voodoo.m3u
/usr/test/W/Wall of Voodoo/Dark = Continent/Dark=20 Continent.m3u
/usr/test/W/Wall of Voodoo/WoV Live/WoV=20 Live.m3u
/usr/test/W/Weatherman, The/Weatheran,=20 The.m3u
/usr/test/W/Weatherman, The/Global 851/Global=20 851.m3u
/usr/test/W/When in Rome/When in = Rome.m3u
/usr/test/W/White=20 Town/White Town.m3u
/usr/test/W/Wil Smith/Wil Smith.m3u
 
It is ok for parent directories to = include mp3s=20 from subdirectories... so Weatherman, The.m3u would also include the = mp3s in=20 it's subdirectory.
 
With help, I have been able to figure = out how to=20 get a list of the subdirectories, wrap the subdirectories in qoutes but = after=20 that is where it all falls apart.  My script seems to disregard the = qoutes=20 I put in there and sees the spaces and then fails = miserably.
 
I haven't been able to get specifically = named m3u=20 files, but putting a songs.m3u file in each directory will work just as=20 good.  I have tried 2 scripts so far.  One that wraps the = directory in=20 qoutes
"/usr/test/W/Weatherman, The/Global=20 851/"
and one that builds the directory like = Unix does=20 when you tab out the directory:
/usr/test/W/Weatherman,\ The/Global\=20 851/
 
SCRIPT 1
#!/bin/sh
       =20 #
        #  Catalog MP3 = files on a=20 directory basis
       =20 #
MP3_ROOT=3D"/usr/test"
# Find Directories under /usr/test then = wrap entire=20 directory in qoutes to encompass spaces
for mp3_dir in `find = $MP3_ROOT -type=20 d -print | sed -e 's/^/\"/' -e 's/$/\"/'` ; do
        = # Find=20 mp3 files in individual directories, clean them up for playlist, dump to = m3u=20 file in that directory
        = find=20 $mp3_dir -iname '*.mp3' # | sed -e  = 's;/usr/test;http://12.159.64.5;' -e=20 's/ /%20/g' > $mp3_dir/songs.m3u
done
 
When I run this script, though, this is = what I=20 get.
-snip-
root:/usr/test>./parse
find: = ./parse: cannot=20 create "/usr/test"/songs.m3u: directory nonexistent
"/usr/test": No = such file=20 or directory
find: ./parse: cannot create "/usr/test/W"/songs.m3u: = directory=20 nonexistent
"/usr/test/W": No such file or directory
find: = ./parse: cannot=20 create "/usr/test/W/Wall/songs.m3u: directory = nonexistent
"/usr/test/W/Wall:=20 No such file or directory
-snip
 
SCRIPT 2
#!/bin/sh
       =20 #
        #  Catalog MP3 = files on a=20 directory basis
       =20 #
MP3_ROOT=3D"/usr/test"
for mp3_dir in `find $MP3_ROOT -type d = -print | sed=20 -e 's/ /\\ /'` ; do
        find = $mp3_dir=20 -iname "*.mp3" | sed -e  's;/usr/test;http://12.159.64.5;' -e 's/ = /%20/g'=20 > $mp3_dir/songs.m3u
done
 
And when I run this script = -snip-
find: ./parse: cannot create=20 /usr/test/W/Wall/songs.m3u: directory nonexistent
/usr/test/W/Wall: = No such=20 file or directory
find: ./parse: cannot create of/songs.m3u: = directory=20 nonexistent
of: No such file or directory
find: ./parse: cannot = create=20 Voodoo/songs.m3u: directory nonexistent
Voodoo: No such file or=20 directory
-snip-
------=_NextPart_000_0015_01C175E9.D905A4A0-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message