Hello all,
I am developing programs for image processing. I want to create prototypes in perl however my knowledge of perl scripting is limited. how would I accomplish the following:

You've just loaded a CD's worth of reference images from an outside company. The images follow a naming scheme such as DSCN-1.JPG, DSCN-2.JPG ... DSCN-10.JPG, although the frame numbers may be noncontiguous (i.e., there may be gaps between numbers).

Although the frames were stored in separate directories on the CD-ROM from which they were loaded, all of the frames have now been placed into this directory:

/shots/spi/home/pix/out/home_test_v1/misc_bg8
The structure of the directory you've loaded them into is this:
/shots/$SHOWNAME/$SHOTNAME/pix/out/$ELEMENTNAME/$RESOLUTION_$COLORSPAC +E
Your task is to rename the frames in accordance with SPI standard naming conventions. These include:

1. No capital letters in the filenames

2. No dashes allowed in the filenames

3. The images should be re-numbered so that they are a contiguous sequence (i.e. no gaps)

4. Frame numbers need to be padded to four-digits. ie, "1" becomes "0001" This is denoted by the symbol # so a range of 1-240 would read 1-240#.

5. The frames should be renamed to match the directory in which they are placed in the following manner:

$ELEMENTNAME_$RESOLUTION_$COLORSPACE.#.$EXTENSION
So, in other words, each frame should become:
/shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.00 +01.jpg /shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.00 +02.jpg /shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.00 +03.jpg ... /shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.02 +40.jpg
However, the incoming frames are part of a series and must be kept in the exact same order as they were when loaded (i.e., the incoming frame with the lowest index will map to `home_test_v1_misc_bg8.0001.jpg', while the second lowest index will map to `home_test_v1_misc_bg8.0002.jpg', and so on).

Please help


In reply to file sorting question by tech2040

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.