On Fri, 20 Apr 2001, Emmanuel Seyman wrote:

> On Fri, Apr 20, 2001 at 08:15:59AM -0500, Jim Baxter a ecrit:
> > Hi
> >
> > Is there a way to rename all the files in a directory the end with .123
> > to end with .src ?
>
> Several, actually:
>
> You can use the rename program from the util-linux rpm and use it:
>       rename ".123" ".src" *.123
>
> You can use Larry Wall's rename script, written in Perl:
>
> #!/usr/bin/perl -w
> # rename - Larry's filename mixer
> $op = shift or die "Usage: rename expr [files]\n";
> chomp(@ARGV = <STDIN>) unless @ARGV;
> for (@ARGV) {
>         $was = $_;
>         eval $op;
>         die $@ if$@;
>         rename($was,$_) unless $was eq $_;
> }
>
>       rename "s/123$/src/" *.123

or you can just take advantage of the bash shell, to wit:

for i in *.123 ; do
> prefix=$(basename $i .123)
> mv $i $prefix.src            (use "mv -i" if you want to be prompted)
> done

it's not at all clear that one wants to invoke perl when the shell
will do it all.

rday

-- 
Robert P. J. Day
Eno River Technologies, Durham NC
Unix, Linux and Open Source training


"This is Microsoft technical support.  How may I misinform you?"



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to