Bash script for files with spaces in the filenames

Mathieu Chouquet-Stringer ml2news at free.fr
Thu Feb 16 13:30:30 UTC 2006


jvian10 at charter.net (Jeff Vian) writes:
> On Thu, 2006-02-16 at 11:29 +0200, Dotan Cohen wrote:
> > #!/bin/bash
> > PWD=`pwd`
> > for file in `find $PWD -name "*.mp3"`
> > do
> >   eyeD3 --force-update --set-encoding=utf8 "$file"
> > done
> > 
> In the above construct $file gets the first part up to the delimiter
> (white space) for each part it reads, so it may not have the full file
> name.
> 
> I had a similar problem so I built something like this:

Just replace the for loop by a while loop:
find $PWD -name "*.mp3" | while read file

And you should be good to go...
-- 
Mathieu Chouquet-Stringer
    "Le disparu, si l'on vénère sa mémoire, est plus présent et
                 plus puissant que le vivant".
           -- Antoine de Saint-Exupéry, Citadelle --




More information about the fedora-list mailing list