Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: File Name Pattern

by lemming (Priest)
on Dec 13, 2002 at 16:56 UTC ( #219641=note: print w/ replies, xml ) Need Help??


in reply to File Name Pattern

You'll probably want to use something like grep /\.jpg/, readdir(DIR) to get your list of files. You might even want to sort them, as you go through, split off the back extension, and check the prefix.

You'll want to check to make sure your prefix is just made of digits. If not, figure out what you want to do with it. If so, sprintf("%06d", $var) for your new prefix and look into substr for getting the first three chars of that.

Then go ahead and make your sub-directories as needed, and make sure you already don't have the numbered file before you rename it. Since your original dir may have a 001234.jpg and 01234.jpg in it.


Comment on Re: File Name Pattern
Select or Download Code

Log In?
Username:
Password:

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

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

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls