Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: How to prefix a string to all the files in a directories as well subdirectories

by perladdict (Chaplain)
on Dec 30, 2008 at 09:10 UTC ( #733208=note: print w/ replies, xml ) Need Help??


in reply to Re: How to prefix a string to all the files in a directories as well subdirectories
in thread How to prefix a string to all the files in a directories as well subdirectories

Hi leocharre, Thanks for your quick reply.
I am not intended to rename directories as well sub directories, all of these directories and subdirectories stores mobile application screen shot in .bmp files with name first_screen.bmp in all directoris. Only thing i want to prefix a string
"reference_" to all of these files recursively.Can u help me out how efficianlty i can prefix a string to all these files.Thanks in advance for your reply.


Comment on Re^2: How to prefix a string to all the files in a directories as well subdirectories
Re^3: How to prefix a string to all the files in a directories as well subdirectories
by cdarke (Prior) on Dec 30, 2008 at 10:53 UTC
    Like this:
    #!/usr/bin/perl use strict; use warnings; use File::Find; sub callback { my $file = $_; rename $file,"reference_$file" if -f $file } my $dir = 'C:/Image_Repository'; find (\&callback, $dir);
    Of course, there is always More Than One Way To Do It, so you can "hand craft" it if you enjoy lots of typing, but it probably won't be as efficient as using File::Find.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (15)
As of 2014-07-30 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls