#!/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__