"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??"

use printf or sprintf:

printf("%06d\n",$_) for (123, 1234, 12345, 123456); my $val = sprintf("%06d",123);
To get the first three digits:
my $name = '012345'; my ($three) = $name =~ /^(\d\d\d)/;
You might want to look at File::MMagic if you have to ensure that the files really are jpg's.

UPDATE:
more code for you :)

use strict; while (<DATA>) { chomp; my ($numbs) = $_ =~ /^(\d+)/; my $formatted = sprintf("%06d",$numbs) . '.jpg'; my ($dir) = $formatted =~ /^(\d\d\d)/; print "filename: $formatted\t\tdirname: $dir\n"; } __DATA__ 123.jpg 1234.jpg 12345.jpg 123456.jpg

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: File Name Pattern by jeffa
in thread File Name Pattern by LostS

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.