opendir(DIR,"$FOLDERNAME") or die $!; #Look through the tiffs for one we care about while ( $FILE = readdir(DIR)) { #check for tif's in folder starting with at least 3 numbers since they have the ISBN in it if ( $FILE =~ /^[0-9][0-9][0-9].*\.tif/ ) { $FILE =~ s/([0-9]*).*/$1/; print $BOOKNAME."'s ISBN is: ".$FILE."\n"; }