From owner-freebsd-questions Sun Nov 25 23:49:12 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-31-203-60.mmcable.com [65.31.203.60]) by hub.freebsd.org (Postfix) with SMTP id 8520F37B417 for ; Sun, 25 Nov 2001 23:49:05 -0800 (PST) Received: (qmail 36129 invoked by uid 100); 26 Nov 2001 07:49:04 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15361.62448.90570.917298@guru.mired.org> Date: Mon, 26 Nov 2001 01:49:04 -0600 To: "Totally Jayyness" Cc: questions@freebsd.org Subject: Re: Scripting Problems please help In-Reply-To: <66931026@toto.iv> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ 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 Totally Jayyness types: > 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 = It would be less bother if you fixed your mailer to send just one copy of the message as plain text, instead of one copy as plain text and another as HTML. At least it wasn't pure HTML. > 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 = Yup. That makes things more difficult. > 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. This has been gone over recently. The problem is shell evaluation in loops doesn't work the obvious way. Or possibly at all. So you have to get the names with spaces in them in a variable *outside* of the loops. Read works nicely for this: #!/bin/sh find . -type d -print | while read x do (cd "$x"; ls *.mp3 > "$x.m3u") done Read solves the problems with spaces and loops. I put the cd and ls in parens to get it in a subshell so the next iteration of the loop will happen in the top directory. It might not be required, but I'm paranoid. http://www.mired.org/home/mwm/ Q: How do you make the gods laugh? A: Tell them your plans. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message