CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
need a batch file renamer that does a specific job

 



mozkill
Novice

Jun 24, 2002, 4:36 PM

Post #1 of 2 (572 views)
need a batch file renamer that does a specific job Can't Post

i have used a 3rd party batch renamer to rename all my mp3 files to lower case with spaces in between the words.

i need a perl script that will uppercase the first letter in each word, but not the first letter in the file extension, for all of my 6000 mp3 files.


davorg
Thaumaturge

Jun 25, 2002, 8:05 AM

Post #2 of 2 (570 views)
Re: [mozkill] need a batch file renamer that does a specific job [In reply to] Can't Post

Something like this perhaps:

Code
#!/usr/bin/perl -w 
# rename.pl

use strict;
use File::Copy;

foreach (@ARGV) {
my ($name, $ext) = split /\./, $_, 2;

my $new_name = $name;
$new_name =~ s/([a-z0-9]+)/ucfirst lc $1/ige;

move "$name.$ext", "$new_name.$ext";
}

Sample usage:

Code
$ ls *.mp3 
something else - some other band.mp3
something - some band.mp3
$ ./rename.pl *.mp3
$ ls *.mp3
Something Else - Some Other Band.mp3
Something - Some Band.mp3


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives