Thread Alle Dateien eines Formats suchen... (13 answers)
Opened by KarlaCluft at 2013-01-27 18:54

topeg
 2013-01-27 21:31
#165214 #165214
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
use strict;
use warnings;

my $path='/home/backup/';

opendir(my $dh, $path) or die("Can't open dir $path");
while( my $file=readdir($dh) )
{
  my $file_path=File::Spec->join($path,$file);
  next unless -f $file_path;
  print "$1\n" if($file=~/([^.]+)$/);
}
closedir($dh);


oder

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use strict;
use warnings;

my $path='/home/backup/';

opendir(my $dh, $path) or die("Can't open dir $path");
while( my $file=readdir($dh) )
{
  my $file_path=File::Spec->join($path,$file);
  next unless -f $file_path;
  my $ending=(split(/\./,$file))[-1];
  print "$ending\n";
}
closedir($dh);

View full thread Alle Dateien eines Formats suchen...