Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How do I do a bulk rename?

by kryberg (Pilgrim)
on Oct 23, 2002 at 15:10 UTC ( [id://207415]=note: print w/replies, xml ) Need Help??


in reply to How do I do a bulk rename?

#!/usr/bin/perl -w # rename all files with a certain extention in a directory use strict; my $dirname; $dirname = '/substitue_your_path_here'; opendir(DIR, $dirname) or die "Can't opendir $dirname: $!"; while ( defined (my $file = readdir DIR) ) { # ignore current and parent directory . and .. next if $file =~ /^\.\.?$/; my $new = $file; # substitute new file extension $new =~ s/\.old_extension$/\.new_extension/; rename($file,$new) }
Reference Perl Cookbook Chapter 9 and Programming Perl Chapter 29

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://207415]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-25 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found