1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
#!/usr/bin/perl # # ToDo # Ausgabe im Wiki-Format für die Dokumenation use strict; use warnings; use 5.010; use Cwd; use File::Spec; use Getopt::Long; use File::Find::Rule; $| = 1; my $PROGNAME = ( split m|[\\/]|, $0 )[-1]; help() if !@ARGV; my ( @filemask, @dir ); my ( $wiki_output, $help, $from, $to); GetOptions( "f|file=s" => \@filemask, # filemasks to select several files (DEFAULT: all files) "d|dir=s" => \@dir, # dirs for scan (DEFAULT: current dir) "wiki" => \$wiki_output, # report in wiki-format (DEFAULT: off) "from=i" => \$from, # zoom level FROM (or min) "to=i" => \$to, # zoom level TO (or max) "h|help" => \$help # show help ) or die "Error in command line arguments\n"; ### set defaults of parameters if not already set push @dir, Cwd::cwd() if not @dir; # use current dir, if no parameter --dir defined $wiki_output //= 0; help() if $help; if (not @filemask) { say "!!!! ##ERROR## !!!! filemask must not be empty!\n"; help(); } for my $i ($from .. $to) { #### search files print "Zoomstufe ".$i."\n"; my $rule = File::Find::Rule->new(); # count of files to have action my $total_count = 0; $rule->name(@filemask); # set filemasks for search $rule->exec( # this sub is called for each matched file of search sub { #my ( $shortfn, $dir.$i."\\", $filename ) = @_; my ( $shortfn, $dir, $filename ) = @_; $dir .= $i."\\"; $filename = File::Spec->rel2abs($filename); $total_count++; } ); print "zaehle .....\r"; $rule->in(@dir); #start search in dirs now print "total files: ".$total_count."\r"; print "\n"; }#end-for exit; # ----------------------------------------------------------------------------- # ------------------------------------ sub help { print <<"HELP"; Usage: $PROGNAME --file=FILEMASK --dir=DIR1 Parameters: --dir Selected directory --file Filemask for selecting several files --wiki Output in Wiki-Table-Format --help This help Example: $PROGNAME --file=a.[12]* -d=X:\\TEST HELP exit 4711; } __END__
for my $i ($from .. $to) {
$dir .= $i."\\";
my ( $shortfn, $dir.$i."\\", $filename ) = @_;
my ( $shortfn, $dir.$i."\\", $filename ) = @_;
$dir .= $i."\\";
$rule->in(map { $_.$i."\\" } @dir);
QuoteAber meine Kristallkugel sagt, mir, dass du vielleicht sowas in der Art wollen könntest. PS: Ich hab mit / statt \ bessere Erfahrungen.
2014-11-19T14:53:33 jan99Du meinst msg #177948?Moin !
leider finde ich das Posting was die Basis für diesen Code nicht wieder....
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
for my $i ($from .. $to) { #### search files print "Zoomstufe ".$i."\n"; my $rule = File::Find::Rule->new(); # count of files to have action my $total_count = 0; $rule->name(@filemask); # set filemasks for search $rule->exec( # this sub is called for each matched file of search sub { my ( $shortfn, $dir, $filename ) = @_; $filename = File::Spec->rel2abs($filename); $total_count++; } ); print "zaehle .....\r"; my @mydirs = map { $_ . $i . "\\" } @dir; $rule->in(@mydirs); #start search in dirs now print "total files: ".$total_count."\r"; print "\n"; }#end-for