Re: [SLUG] filenames with spaces

From: Eben King (eben1@tampabay.rr.com)
Date: Fri May 07 2004 - 22:12:34 EDT


On Fri, 7 May 2004, Steve wrote:
> On Friday 07 May 2004 12:03 pm, Eben King wrote:

> > find $Dir -name "*.wma" | while read filename ; do
> > echo " $filename"
> > mplayer -ao pcm "$filename"
> > done
> >
> > If $Dir has a space in its name, you need to put it in "" too.
>
> Thanks!
>
> I like open lines as they are easier to read and modify.
>
> The only thing wrong is that $filename needs / to cover each of the spaces
> and symbols in the names. Pretty much every directory and song has both
> spaces and symbols in their names. Ex:
>
> /MyMusic/Creed/Human Clay/06 Faceless Man [US Version].wma
>
> The code looks like this now:
>
> Dir="/home/s/MyMusic"
> CDir="`pwd`"
> cd $Dir
> i=1
>
> find "$Dir" -name "*.wma" |xargs -0 while read song ; do

I don't think you want "xargs while". It may work, but if so, all of the
iteration would be done by the "while", which makes the "xargs"
superfluous.

It doesn't matter how many files "find" finds; the list isn't being
handled by a shell, so isn't subject to the 20k (or whatever) limit that
necessitates "xargs".

> echo "$i $song"
> #mplayer -ao pcm "$song"
> i=$(($i+1))

Is "i" ever reset to 1 (except at the top of the script)? Or is it a song
counter? If the latter, instead of performing 10000 (or however many
songs you have) iterations of "i=i+1", it may be faster to perform one
iteration of "i=`find "$Dir" -type f | wc -l`".

> if [ "`ls -l audiodump.wav|cut -d' ' -f6`" -gt "100" ] ;then

Where did audiodump.wav come from? I assume it's from a wma -> wav
conversion. Surely there's a more efficient way of finding the wma's
length...

"if [[ `wc -c < audiodump.wav` -gt 100 ]]" may be faster than what's
there.

> echo "Converting to ogg"
> fi
> #sleep 2
> exit 0
> done
>
> cd "$CDir"

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
SCORPIO:  Get ready for an unexpected trip when you fall screaming
from an open window.  Work a little harder on improving your low self
esteem, you stupid freak.  -- Weird Al, _Your Horoscope for Today_

----------------------------------------------------------------------- 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:55:50 EDT