flieckster has asked for the wisdom of the Perl Monks concerning the following question:
Hello, i'm trying to remove the suffix from a list of filenames. what is the best way to apply the basename module to a list of files.?
when i run this the print function will print the same filename for as many times as there are files it globbed, and doesn't make it into my email. LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT LT-AG4437_AH66-FLAT#!/usr/bin/env perl use Net::FTP; use File::Copy; use Mail::Sender; use Net::SMTP; my $TIFFfolder = "/Volumes/photorepos/Partners/LTBrands/post/DONE_PSDs +/"; chdir( $TIFFfolder ) or warn "Cant chdir to $TIFFfolder $!"; my(@TIFFfolder_list) = glob "*.psd"; print "$date $time Removing any Thumbs.db files from $TIFFfolder\n"; if ( -e "Thumbs.db") { unlink ("Thumbs.db") or warn "thumbs.db is being a pain in the ass: $! +\n"; } my $TIFFapproval = @TIFFfolder_list; foreach $file (@TIFFfolder_list){ my $file = basename (@TIFFfolder_list, ".psd"); print "$file\n"; } $mail->send(-to=>"$to", -from=>"$from", -subject=>"$subject", -body=>" +$file", -contenttype=>"text/html"); $mail->bye;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: using basename on a list of filesnames
by haukex (Archbishop) on Nov 13, 2019 at 04:58 UTC | |
Re: using basename on a list of filesnames
by roboticus (Chancellor) on Nov 13, 2019 at 03:46 UTC | |
Re: using basename on a list of filesnames
by 1nickt (Canon) on Nov 13, 2019 at 00:07 UTC | |
by flieckster (Scribe) on Nov 13, 2019 at 02:08 UTC | |
by 1nickt (Canon) on Nov 13, 2019 at 03:51 UTC | |
Re: using basename on a list of filesnames
by jcb (Parson) on Nov 13, 2019 at 04:27 UTC | |
by 1nickt (Canon) on Nov 13, 2019 at 05:03 UTC | |
by jcb (Parson) on Nov 14, 2019 at 00:35 UTC |
Back to
Seekers of Perl Wisdom