Date: Sun, 25 Nov 2001 19:46:17 -0700 From: "Totally Jayyness" <Jayyness@mindspring.com> To: <freebsd-questions@freebsd.org> Subject: Scripting Problems please help Message-ID: <001801c17624$85c958f0$0300a8c0@jayyness.com>
next in thread | raw e-mail | index | archive | help
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 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV> <DIV><FONT face=3DArial size=3D2>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.)</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>OK, I have mp3 files n several = directories. =20 Here is a sample of directories.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial = size=3D2>/usr/test<BR>/usr/test/W<BR>/usr/test/W/Wall of=20 Voodoo<BR>/usr/test/W/Wall of Voodoo/Dark Continent<BR>/usr/test/W/Wall = of=20 Voodoo/WoV Live<BR>/usr/test/W/Weatherman, = The<BR>/usr/test/W/Weatherman,=20 The/Global 851<BR>/usr/test/W/When in Rome<BR>/usr/test/W/White=20 Town<BR>/usr/test/W/Wil Smith</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>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..</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial=20 size=3D2>/usr/test/test.m3u<BR>/usr/test/W/W.m3u<BR>/usr/test/W/Wall of=20 Voodoo/Wall of Voodoo.m3u<BR>/usr/test/W/Wall of Voodoo/Dark = Continent/Dark=20 Continent.m3u<BR>/usr/test/W/Wall of Voodoo/WoV Live/WoV=20 Live.m3u<BR>/usr/test/W/Weatherman, The/Weatheran,=20 The.m3u<BR>/usr/test/W/Weatherman, The/Global 851/Global=20 851.m3u<BR>/usr/test/W/When in Rome/When in = Rome.m3u<BR>/usr/test/W/White=20 Town/White Town.m3u<BR>/usr/test/W/Wil Smith/Wil Smith.m3u</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>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.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>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.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>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 </FONT></DIV> <DIV><FONT face=3DArial size=3D2>"/usr/test/W/Weatherman, The/Global=20 851/"</FONT></DIV> <DIV><FONT face=3DArial size=3D2>and one that builds the directory like = Unix does=20 when you tab out the directory: <DIV><FONT face=3DArial size=3D2>/usr/test/W/Weatherman,\ The/Global\=20 851/</FONT></DIV></FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>SCRIPT 1</FONT></DIV> <DIV><FONT face=3DArial=20 size=3D2>#!/bin/sh<BR> =20 #<BR> # Catalog MP3 = files on a=20 directory basis<BR> =20 #<BR>MP3_ROOT=3D"/usr/test"</FONT></DIV> <DIV><FONT face=3DArial size=3D2># Find Directories under /usr/test then = wrap entire=20 directory in qoutes to encompass spaces<BR>for mp3_dir in `find = $MP3_ROOT -type=20 d -print | sed -e 's/^/\"/' -e 's/$/\"/'` ; do</FONT></DIV> <DIV><FONT face=3DArial size=3D2> = # Find=20 mp3 files in individual directories, clean them up for playlist, dump to = m3u=20 file in that directory<BR> = 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<BR>done</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>When I run this script, though, this is = what I=20 get.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>-snip-</FONT></DIV> <DIV><FONT face=3DArial size=3D2>root:/usr/test>./parse<BR>find: = ./parse: cannot=20 create "/usr/test"/songs.m3u: directory nonexistent<BR>"/usr/test": No = such file=20 or directory<BR>find: ./parse: cannot create "/usr/test/W"/songs.m3u: = directory=20 nonexistent<BR>"/usr/test/W": No such file or directory<BR>find: = ./parse: cannot=20 create "/usr/test/W/Wall/songs.m3u: directory = nonexistent<BR>"/usr/test/W/Wall:=20 No such file or directory</FONT></DIV> <DIV><FONT face=3DArial size=3D2>-snip</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>SCRIPT 2</FONT></DIV> <DIV><FONT face=3DArial=20 size=3D2>#!/bin/sh<BR> =20 #<BR> # Catalog MP3 = files on a=20 directory basis<BR> =20 #<BR>MP3_ROOT=3D"/usr/test"<BR>for mp3_dir in `find $MP3_ROOT -type d = -print | sed=20 -e 's/ /\\ /'` ; do<BR> 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<BR>done</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>And when I run this script = -snip-</FONT></DIV> <DIV><FONT face=3DArial size=3D2>find: ./parse: cannot create=20 /usr/test/W/Wall/songs.m3u: directory nonexistent<BR>/usr/test/W/Wall: = No such=20 file or directory<BR>find: ./parse: cannot create of/songs.m3u: = directory=20 nonexistent<BR>of: No such file or directory<BR>find: ./parse: cannot = create=20 Voodoo/songs.m3u: directory nonexistent<BR>Voodoo: No such file or=20 directory</FONT></DIV> <DIV><FONT face=3DArial size=3D2>-snip-</FONT></DIV></DIV></BODY></HTML> ------=_NextPart_000_0015_01C175E9.D905A4A0-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001801c17624$85c958f0$0300a8c0>