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

Re: yet another bash question

On Tue, Nov 07, 2006 at 03:16:38PM +0000, Richard Lyons wrote:
> For things like saving photos to hard disk, I tend to use a few bash scripts
> to rename the files, keeping the numerical part and coding something else in
> place of the "cimg".  For example, I might change all the files cimg1234.jpg
> to cimg1299.jpg to be called foobar234.jpg to foobar299.jpg. I tend to
> modify these scripts when need arises, but the latest one shows an oddity I
> cannot understand.  
The renaming can be more efficiently accomplished using the rename
command.  It is part of Perl and uses Perl-type REs, go figure. Anyhow,
something like this would do what you want:

rename 's/cimg/foobar/' *.jpg



Roberto C. Sanchez

Reply to: