Re: [SLUG] filenames with spaces

From: Paul M Foster (paulf@quillandmouse.com)
Date: Fri May 07 2004 - 14:32:35 EDT


On Fri, May 07, 2004 at 12:03:58PM -0400, Eben King wrote:

> On Fri, 7 May 2004, Logan Tygart wrote:
>
> > On Thu, 2004-05-06 at 22:48, Steve wrote:
> > <snip>
> > > The problem is that there are spaces in the file and directory names
> which I
> > > inherited from a windows machine.
> > <snip>
> >
> > Sounds like a job for a PERL script.
>
> Bah.
>
> find $Dir -name "*.wma" | while read filename ; do
> echo " $filename"
> mplayer -ao pcm "$filename"
> done
>

I toyed with this a little last night and couldn't find a good solution.
The above works, though.

The real problem isn't so much the spaces in the filenames as the fact
that the way the loop was written, it dumped all the results at once,
instead of one result per iteration. Hence, mplayer would have who knows
how many filenames given to it at once on the command line.

This question has come up before, and usually stems from the fact that
our first inclination at a way to solve it doesn't work under bash the
way we expect it to. Programs like "find" and "ls" don't dump one result
at a time into a loop; instead, it's all at once, which is usually not
what we want.

Paul
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:54:20 EDT