TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:18790] quick way to strip spaces...



David Wood wrote:
> 
> On Fri, 9 Jun 2000, Brian Ackermann wrote:
> 
> > anybody got a quick way strip spaces from a filename, preferably one that
> > will do globbing and perhaps recursion?
> >
> > I've got a whole bunch of mp3 uploaded to my new RIMPS server, from various
> > places, and I'd really like to eliminate the spaces in the names.  Rimps
> > works just fine with them, but its troublesome to me...
> 
> for i in `find -name *.mp3`; do mv $i `echo $i | sed s/\ /-/`; done

Actually, I think you may not be correctly encapsulating the $i's..  It
might work better to use

for i in `find -name *.mp3'; do mv "$i" `echo $i | sed s/\ /-/`; done

I've noticed that filename parsing can be difficult sometimes, so this
might not work either..

> That should replace spaces with -'s.  Some prefer _'s, but I hate having to
> hit shift all day ;)
> 
> It also recurses, etc.  You can pop in an echo $i before the mv to see the
> progress as it goes as well.
> 
> Anyhow, have at it.. there's my scriptlet for the day.
> 
> -David
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org

-- 
 _  _  _  _ _  ___    _ _  _  ___ _ _  __   Don't confuse me with the 
/ \/ \(_)| ' // ._\  / - \(_)/ ./| ' /(__   facts. 
\_||_/|_||_|_\\___/  \_-_/|_|\__\|_|_\ __)                             
[ Mike Hicks | http://umn.edu/~hick0088/ | mailto:hick0088@tc.umn.edu ]