Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Re: Renaming Files

by blakem (Monsignor)
on Aug 23, 2001 at 04:07 UTC ( [id://107204]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Renaming Files
in thread Renaming Files

Warning, untested code...

how about something like:

my $dir = '/my/mp3/directory'; opendir(DIR,$dir) or die "Cannot open $dir: $!"; while(defined($subdir = readdir(DIR))) { next if $subdir =~ /^\./; next unless -d "$dir/$subdir"; opendir(DIR2,"$dir/$subdir") or die "Cannot open $dir/subdir: $!"; while (defined($file = readdir(DIR2))) { next unless $file =~ /\.mp3$/i; my $src = "$dir/$subdir/$file"; my $dest = "$dir/$subdir/${subdir}_$file"; print "renaming $src => $dest\n"; # rename $src, $dest; } }

-Blake

Replies are listed 'Best First'.
Re: Re: Re: Re: Renaming Files
by jmoloug1 (Initiate) on Aug 23, 2001 at 05:48 UTC
    Dude, your code rocks! With some quick mods, I also changed all TXT DOC and JPG files in the same directories. Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-25 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found