Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Nov 2001 01:49:04 -0600
From:      Mike Meyer <mwm@mired.org>
To:        "Totally Jayyness" <Jayyness@mindspring.com>
Cc:        questions@freebsd.org
Subject:   Re: Scripting Problems please help
Message-ID:  <15361.62448.90570.917298@guru.mired.org>
In-Reply-To: <66931026@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Totally Jayyness <Jayyness@mindspring.com> 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.

	<mike
--
Mike Meyer <mwm@mired.org>			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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15361.62448.90570.917298>