1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
my $dir = 'C:/Users/'; my $body; my @file = (""); opendir( MYDIR, $dir ) or die 'opendir'; $body = join( "\n", readdir MYDIR ); closedir MYDIR; #print "$body"; if ("$body =~ m/\.csv$/" cmp "$body =~ m/\.csv.xls$/") {} else {push (my $file);} print "$file"; exit 0;
2018-08-07T18:51:07 dirk.mCode (perl): (dl )if ("$body =~ m/\.csv$/" cmp "$body =~ m/\.csv.xls$/")
1 2 3 4 5 6 7
opendir(my $dirh, "."); my @all = grep/\.csv(\.xlsx?)?$/i, readdir $dirh; my %excel; @excel{map lc, grep /\.xlsx?$/i, @all} = (); for(grep $_ !~ /.xlsx?$/i, @all) { say unless exists $excel{lc "$_.xlsx"} || exists $excel{lc "$_.xls"}; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
my $dir = 'C:/Users'; my @new_csv_files; opendir my $dh, $dir or die "opendir($dir) failed: $!"; chdir $dir; while ( my $filename = readdir $dh ) { if ( substr( $filename, -4, 4 ) eq '.csv' ) { if ( not -e "$filename.xls" ) { push @new_csv_files, $filename; } } } closedir $dh; # und jetzt die Dateien in @new_csv_files verarbeiten. # Beachte, dass hier nur die Dateinamen drin stehen, nicht der Verzeichnis-Pfad!