in reply to A monk in training with a problem

You seem to be asking the Monks to write your code for you. Please have a look at this.

Here is a quick guide on how to do it:

you will need to open the dir/s  perlfunc:opendir

read the contents of the dir/s perlfunc:readdir
use a conditional construct perlman:perlfunc
and a match type regexp perlfunc:m
rename your files perlfunc:rename
open your database text file perlfunc:open
print to your DB text file perlfunc:print
close you database file perlfunc:close

tachyon

Replies are listed 'Best First'.
Re: Re: A monk in training with a problem
by wiz (Scribe) on Jun 12, 2001 at 03:09 UTC
    #!/usr/bin/perl -w use diagnostics; use strict; sub getgoodfiles { @4by6 = glob(/* 4 by 6.tif\); @screenres = glob(/* screen res.tif\); @thumbnail = glob(/* thumbnail.jpg\); sort @4by6; sort @screenres; sort @thumbnail; }
    would this work for getting all the files i need and organizing them?
      That's a good start as semi-pseudocode, but your example will never compile :
      1. you're using strict, which requires variables to be declared with my. You fail to do this.
      2. 4by6 is not a valid variable name, as it starts with a number.
      3. the parameters you pass to glob are incorrect. Glob expects string values, and you've provided some freeform text that resembles an unterminated regex.
      4. sort will not change the parameters it's passed, thus requiring, e.g.,  my @screenres=sort @screenres. However, you can just as easily write  @screenres=sort glob("* screen res.tif");
      5. Where are your files being stored? Unless a path is specified, glob uses the root directory as a default (I tested this under WinMe, does this hold true for *nix?). Specify your path in glob :  my @screenres=sort glob("c:/example/images/* screen res.tif");

        Better yet, separate your path out into its own variable for maintenance purposes:

        my $imagepath= "C:/example/images/"; my @screenres=sort glob("$imagepath* screen res.tif");
      You are doing some good things, which most beginners miss :
      1. using strict
      2. using diagnostics (useful for new perl coders)
      3. splitting work into subs
      I hope this makes some sense.

      for the first step of your request :

      A) The name is changed to something like 000014b6.tif, 00001sr.jpg, and 00001tn.jpg. (and possibly 000018b10.tif)
      I would recommend using an underscore between the file name and the picture type, so 00001_4b6.tif and 00001_8b10.tif, and so on. This will assist you in determining where picture names stop, and picture types begin.

      Also, check out the rename command, but since you are so new to perl, please back up all your pictures before commencing with renames :

      Good luck!

      Update a little more experiment with glob seems to reveal its output is always sorted. Can anyone confirm this?