Perhaps something like this (untested) code would work:

#!/usr/bin/perl -w use strict; my $dir = $ARGV[0]; # first command line argument opendir D, $dir or die "can't open $dir: $!\n"; # for each file in directory: my $file; while ($file = readdir(D)) { # only process files called "* screen res.jpg" next unless $file =~ /(.*) screen res.jpg/; # but only process them if the corresponding thumbnail exists and is +a file ($1 is the base name) next unless -f "$1 thumbnail.jpg"; # now do the family of renames. rename $file, "${1}sr.jpg" or die "can't rename \"$file\" as \"${1}sr.jpg\": $!\n"; rename "$1 thumbnail.jpg", "${1}tn.jpg" or die "can't rename \"$1 thumbnail.jpg\" as \"${1}tn.jpg\": $!\n"; rename "$1 8 by 10.tif", "${1}8b10.tif"; rename "$1 4 by 6.tif", "${1}4b6.tif"; # open the text file for write and close it again # to make a 0-length file open T, ">${1}.txt" or die "can't open text file ${1}.txt: $!\n"; close T; } closedir D;

update: hmm, "teach a man to fish" vs. "give a man a fish"?
Added comments for clarification.


In reply to Re: A monk in training with a problem by bikeNomad
in thread A monk in training with a problem by wiz

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.