fix(utils): Verboseparameter -v hinzugefuegt; rekursives makedir; genauere Meldungen.
This commit is contained in:
parent
3bc3acf38c
commit
1806d9f01f
@ -3,21 +3,36 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %progparams = ();
|
||||
while(@ARGV > 3) {
|
||||
my $p = shift @ARGV;
|
||||
$progparams{$p} = 1;
|
||||
}
|
||||
|
||||
my $verbose = $progparams{"-v"};
|
||||
|
||||
my ($fromdir, $renamefile, $todir) = @ARGV;
|
||||
|
||||
sub usage {
|
||||
die "usage: $0 [fromdir] [renamefile] [todir]\n
|
||||
my $msg = shift;
|
||||
if($msg) { $msg="\n$msg\n" } else {$msg=''}
|
||||
die "usage: $0 {options} [fromdir] [renamefile] [todir]\n
|
||||
takes files from [fromdir], renames according to the json-map in
|
||||
[renamefile] and writes the files to [todir].
|
||||
old filenames are used as keys; new filenames as value\n";
|
||||
old filenames are used as keys; new filenames as value.
|
||||
|
||||
Options:
|
||||
-v verbose output
|
||||
$msg";
|
||||
}
|
||||
|
||||
usage() unless $fromdir and $renamefile and $todir;
|
||||
usage() unless -d $fromdir;
|
||||
usage() unless -f $renamefile;
|
||||
usage("missing parameters: fromdir renamefile todir needed") unless $fromdir and $renamefile and $todir;
|
||||
usage("fromdir is not a directory") unless -d $fromdir;
|
||||
usage("renamefile is not given") unless -f $renamefile;
|
||||
|
||||
|
||||
mkdir $todir;
|
||||
#mkdir $todir;
|
||||
system("mkdir", '-p', $todir);
|
||||
|
||||
my %did = ();
|
||||
my %params = ();
|
||||
@ -69,7 +84,7 @@ for my $to (keys %toRename) {
|
||||
}
|
||||
|
||||
for(@errNex) {
|
||||
warn "Could not rename non-existent file: $_\n";
|
||||
warn "Could not rename non-existent file: $_\n" if $verbose;
|
||||
}
|
||||
|
||||
die "Syntax error in [renamefile], could not process everything!" if $core!~m#^[\s*,]*$#;
|
||||
@ -78,7 +93,7 @@ my $dh = undef;
|
||||
opendir($dh, $fromdir) or die "Could not read dir '$fromdir', because: $!";
|
||||
while(my $filename = readdir($dh)) {
|
||||
next if $filename=~m#^\.\.?$#;
|
||||
warn "Did not touch not mentioned file '$filename'\n" unless $did{$filename};
|
||||
warn "Did not touch not mentioned file '$filename'\n" unless $did{$filename} or not $verbose;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user