eileen1017
MIS
I have about hundreds of files under the directory /u01/stat/oradata/arch named from 1_1_880795724.dbf to 1_177_880795724.dbf I want to rename all these files to stat_1_1_880795724.arc etc. How can I achieve this in a single command?
I wrote a perl script, but it is not working even for just replacing the file type only.
#!/usr/bin/perl
opendir (DIR, "/u01/stat/oradata/arch");
foreach $file (readdir(DIR)) {
next if $file =~ /^\./; # skip ., .., etc
rename 's/\.dbf$/.arc/' *dbf
}
closedir (DIR);
Operator or semicolon missing before *dbf at ./replace_arch_format.perl line 11.
Ambiguous use of * resolved as operator * at ./replace_arch_format.perl line 11.
Not enough arguments for rename at ./replace_arch_format.perl line 11, near "dbf
}"
Execution of ./replace_arch_format.perl aborted due to compilation errors.
Can gurus advise? Thank you very much.
I wrote a perl script, but it is not working even for just replacing the file type only.
#!/usr/bin/perl
opendir (DIR, "/u01/stat/oradata/arch");
foreach $file (readdir(DIR)) {
next if $file =~ /^\./; # skip ., .., etc
rename 's/\.dbf$/.arc/' *dbf
}
closedir (DIR);
Operator or semicolon missing before *dbf at ./replace_arch_format.perl line 11.
Ambiguous use of * resolved as operator * at ./replace_arch_format.perl line 11.
Not enough arguments for rename at ./replace_arch_format.perl line 11, near "dbf
}"
Execution of ./replace_arch_format.perl aborted due to compilation errors.
Can gurus advise? Thank you very much.