[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Maybe offtopic: Dealing with filenames with blanks in a script



On Thu, Apr 29, 2004 at 10:05:25PM -0600, Dave Thayer wrote:
> On Thu, Apr 29, 2004 at 04:52:22PM +0100, Thomas Adam wrote:
> >  --- Dave Thorn <davet@fysh.org> wrote: 
> > 
> > > On Thu, Apr 29, 2004 at 12:05:59PM +0200, Richard Lyons wrote:
> > > > 
> > > > Does that mean I could have a script to convert all those horrible 
> > > > filenames people give you from the dark side - the ones like
> > > > "Some Thoughts About Your Proposition.doc".  A simple script to
> > > replace 
> > > > all the spaces with underscores.  
> > 
> > Something like this:
> > 
> > rename 's/ /_/g' *
> > 
> > Of course, to be more thorough:
> > 
> > find . -type -f -maxdepth 1 -print0 | xargs -0 rename's/ /_/g'
> 
> And, to camelCase the name you can use:
> rename 's/_(.)/\u$1/g' *
> 

Oops, just realized that that changes undersore_seperated to camelCase. To
go from space seperated the RE should be 's/ (.)/\u$1/g'

dt

-- 
Dave Thayer           | WARNING: Persons denying the existence of 
Denver, Colorado USA  | robots may be robots themselves.
dave@thayer-boyle.com | 



Reply to: