in reply to A monk in training with a problem

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.

Replies are listed 'Best First'.
Re: Re: A monk in training with a problem
by TGI (Parson) on Jun 12, 2001 at 02:16 UTC

    Well, at least nothing's getting unlinked. :)

    UPDATE:

    wiz, check out The books I use for a list of really solid paper resources.


    TGI says moo

    A reply falls below the community's threshold of quality. You may see it by logging in.