Re: scripting question
On Wed, Jul 01, 2009 at 09:28:23AM -0500, Kumar Appaiah wrote:
> On Wed, Jul 01, 2009 at 07:22:33AM -0700, Marc Shapiro wrote:
> > How can I rename all of the files ina directory with the new name
> > being the old name stripped of its leftmost three characters. If
> > all of the files are off the format:
> >
> > xxxyyyyyyyyyyyyyyyyyyyyy.zzz
> >
> > I want the new names to be of the format:
> >
> > yyyyyyyyyyyyyyyyyyyyy.zzz
> >
> > I have hundreds of files like this in each of several directories
> > and I really don't want to do it all by hand. I did some of that,
> > already, and I know there must be a better way.
>
> for i in *zzz;do
> mv "$i" $(echo "$i"|sed 's/^...//');
> done
>
> But I'd recommend one of these: mrename, krename, gprename,
> renameutils and more (all apt-gettable, of course).
Oh, and I think prename (or just rename?) comes with Perl. It should
be something as simple as:
rename 's/^...//' *.zzz
HTH.
Kumar
Reply to: