-v optie ge\"implementeerd, voor verbose/verify kun je eerst
je moves checken. Waarschijnlijk handig samen met -p
This commit is contained in:
parent
5bcdc11ee3
commit
52c46b71a4
1 changed files with 16 additions and 7 deletions
|
|
@ -100,13 +100,17 @@ sub move_files {
|
|||
for ( $i=0; $i < scalar(@$from); $i++ ) {
|
||||
$source=$from->[$i];
|
||||
$target=$to->[$i];
|
||||
unless ( $source eq $target ) {
|
||||
chomp($source);
|
||||
chomp($target);
|
||||
unless ( $source eq $target ) {
|
||||
if ($opt_v) {
|
||||
print "mv $source $target\n";
|
||||
} else {
|
||||
move("$source", "$target")
|
||||
or die "move failed: $!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# read pattern file
|
||||
|
|
@ -139,7 +143,7 @@ sub run_checks {
|
|||
foreach $line (@target) {
|
||||
if ( $line =~ m/^$/ ) {
|
||||
if ( -e ".mv_wrap" ) { unlink (".mv_wrap"); }
|
||||
die "Aborting. You can't move to empy names.\n";
|
||||
die "Aborting. You can't move to empty names.\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,8 +198,12 @@ sub safety_belt {
|
|||
$filename = $source->[$filenr];
|
||||
chomp $filename;
|
||||
$rand = &rand_file;
|
||||
if ($opt_v) {
|
||||
print "mv $filename $rand\n";
|
||||
} else {
|
||||
move("$filename", "$rand")
|
||||
or die "move failed: $!";
|
||||
}
|
||||
$source->[$filenr] = "$rand\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -233,7 +241,7 @@ sub unlock {
|
|||
|
||||
sub cmdline {
|
||||
%optctl = ();
|
||||
&GetOptions("e=s", "h", "p=s", \@pattern, "f=s");
|
||||
&GetOptions("e=s", "h", "p=s", \@pattern, "f=s", "v");
|
||||
&GetOptions(\%optctl, "e");
|
||||
|
||||
&help if $opt_h;
|
||||
|
|
@ -262,6 +270,7 @@ At the moment it takes the following options:
|
|||
-e <editor> invoke with this editor; ignored if -f or -p is given
|
||||
-p <pattern> use a pattern to edit; ignored if -f is given
|
||||
-f <file> use a pattern file to edit
|
||||
-v verify/verbose; shows file moves that would happen without -v
|
||||
|
||||
Specifying fiels on the command line is still unsafe! There are no checks
|
||||
to prevent overwriting non-specified files!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue