Link to home
Start Free TrialLog in
Avatar of taagangel
taagangel

asked on

excluding a subdirectory in a perl script that uploads images to an ftp site

I am dealing with a perl script that runs on a cron to ftp images from one server to another via ftp. Currently the image directories are /listings/residential    /listings/commcercial and so on... each of these directories has a subdirectory for thumbnails... as the script stands now, it ftps all the images and as a result the thumbnails end up overwriting the full size images... Can i easily add to the following code to exclude any subdirectory with the name 'thumb' or thumbnails?
here's the ftp portion of the code:


open(IMG, "< $filelist") or die "$!";
while($file=<IMG>) {
	chomp $file;
	$rs = $ftp->put($file);
	if($rs ne ''){
		&log(sprintf("FTP PUT FILE: %s", $rs));
	}else{
	 	&log(sprintf("FTP PUT ERROR: %s", $file));
	}
}
close(IMG);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adam314
Adam314


open(IMG, "< $filelist") or die "$!";
while($file=<IMG>) {
        chomp $file;
        next if $file =~ /^thumb(nails)?$/i;
        $rs = $ftp->put($file);
        if($rs ne ''){
                &log(sprintf("FTP PUT FILE: %s", $rs));
        }else{
                &log(sprintf("FTP PUT ERROR: %s", $file));
        }
}
close(IMG);

Open in new window

Avatar of taagangel

ASKER

Thanks much!!!!! That did the trick! :-)
Thank you! Another person posted a very similar answer before you did and that one worked. Wish I could give you some points though as yours looks like it would have worked as well.
No problem about the points - but you can split the points among multiple correct answers.