Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming files in current dir

Status
Not open for further replies.

rjuuser

Programmer
Dec 2, 2008
5
Hello,

I'm working off some sample code...

Code:
#!/bin/perl

use strict;
use warnings;

# rename - Larry's filename fixer
my $op = shift or die "Usage: rename expr [files]\n";
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
    my $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}

I'm usign Windows XP and in the command shell

Code:
>rename.pl "s/\.PRC/.txt/" *.PRC
does not do anything. Any ideas why this is not working?
 
Here is your code and question.

Code:
#!/bin/perl

use strict;
use warnings;

# rename - Larry's filename fixer
my $op = shift or die "Usage: rename expr [files]\n";
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
    my $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}

I'm usign Windows XP and in the command shell

Code:
>rename.pl "s/\.PRC/.txt/" *.PRC

does not do anything. Any ideas why this is not working?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Yes, that was my question. Do you have any ideas how should I modify this code to get it work. Your help is most appreciated.
 
Are you wanting to rename all .PRC files to .txt in some directory?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top