go ahead... be a heretic | |
PerlMonks |
File Name Patternby LostS (Friar) |
on Dec 13, 2002 at 16:37 UTC ( [id://219630]=perlquestion: print w/replies, xml ) | Need Help?? |
LostS has asked for the wisdom of the Perl Monks concerning the following question:
Today's Issues is: OK I have a directory full of files. They should all be *.jpg's and be in number format. Here is what I need to do. Look at file name. If file name is not 6 digits (exp: 123456.jpg) add 0 to the front until it is (exp: so 1234.jpg becomes 001234.jpg). Then I need to get those first 3 digits. OK then I need to create a directory by those first 3 digits if it does not already exist. Then move the file with it's new name to that directory. It needs to do this with every file in this directory (approx 42,000 images). OK I guess what I need help with is trying to figure out the regex junk (never been my strong point). I read in the directory how do I do the the match to see if the file is 3 or 4 or 5 or 6 digits long and how would I add the characters to the front of the files and get those first 3 digits?? ----------------------- Billy S. Slinar Hardtail - Hand of Dane Datal Ephialtes - Guildless RallosZek.Net Admin/WebMaster
Back to
Seekers of Perl Wisdom
|
|