Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: I have a folder which is having 1200 files,all the file names are have maximum of 8 character length.I need to remove last character from each of the filnames and prefix it with character "A"

by SuicideJunkie (Priest)
on Feb 20, 2013 at 18:44 UTC ( #1019823=note: print w/ replies, xml ) Need Help??


in reply to I have a folder which is having 1200 files,all the file names are have maximum of 8 character length.I need to remove last character from each of the filnames and prefix it with character "A"

That could also be a job for a regular expression.

Capture up to 7 symbols, then have an optional single symbol, then capture a literal dot and up to three more characters. Then rename the file to 'A' . $1 . $2

The last step is to realize that things have gone horribly wrong with your requirements as stated, when you notice that you are not guaranteed to have unique filenames after losing the last letter, and files start conflicting with each other.


Comment on Re: I have a folder which is having 1200 files,all the file names are have maximum of 8 character length.I need to remove last character from each of the filnames and prefix it with character "A"
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2014-09-16 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (34 votes), past polls