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...:
Mass rename script with alphanumeric sequence

 



perlnewb
New User

Feb 22, 2008, 5:26 AM

Post #1 of 2 (2084 views)
Mass rename script with alphanumeric sequence Can't Post

Hi,

I am looking for a perl script that will mass rename everything within the directory using the given name plus a unique character.

I have found similar scripts that does the above. But they can only do numbers. I need one that can do alphanumerics. Not hexadecimals. Alphanumerics (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ).


hacker01
Novice

Mar 4, 2008, 9:27 AM

Post #2 of 2 (2066 views)
Re: [perlnewb] Mass rename script with alphanumeric sequence [In reply to] Can't Post

I am not sure what you are looking for but this bit of code should help you.


opendir DIR, "$thedir";
@allfiles = readdir DIR;
closedir DIR;

foreach $file(@allfiles) {

$count++;
$newname = "$count";

rename "$thedir/$file", "$thedir/$newname$file";

}

}

exit;

 
 


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

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