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

Re: UPPER to lowercase.

Hans <hansfong@zonnet.nl> wrote:
>I'm trying to get this bash script working which converts filenames from
>UPPER to lowercase. 
>for x in *; do mv $x 'echo $x|tr [A-Z][a-z]'; done;
>It comes back with 'when moving multiple files, last argument must be a
>directory.' I thought this was a loop, so how come it moves multiple files?

People have already suggested variants on this:

  for x in *; do mv $x `echo $x | tr '[A-Z]' '[a-z]'`; done

You could also install the mmv package and try this instead:

  mmv '*' '#l1'

... or this:

  mmv \* \#l1

... depending on what quoting style you prefer. Using backquotes allows
you to do more general transformations, though.

You might also try rename, which comes with the perl-5.005 package.


Colin Watson                                           [cjw44@cam.ac.uk]

Reply to: