diff --git a/mvwrap/mvwrap b/mvwrap/mvwrap index 9669a85..52b6807 100755 --- a/mvwrap/mvwrap +++ b/mvwrap/mvwrap @@ -26,6 +26,8 @@ closedir(DIRHANDLE); &lock; +if ($opt_f) { &read_pattern; } + if (@pattern) { @target = @source; &pattern_edit; @@ -57,6 +59,7 @@ if (@unsafe = &check_safety(\@source, \@target)) { # final move &move_files(\@source, \@target); +if ( -e ".mv_wrap" ) { unlink (".mv_wrap"); } ######################################################## @@ -107,9 +110,14 @@ sub move_files { } } +sub read_pattern { + open PAT, "< $opt_f" or die "Couldn't open pattern file: $?\n"; + @pattern = ; + close PAT; +} + sub pattern_edit { my (@new_target, $pat); - foreach (@target) {print ;} foreach $pat (@pattern) { @new_target=(); foreach(@target) { @@ -117,11 +125,9 @@ sub pattern_edit { push @new_target, $_; } @target = @new_target; - foreach (@target) {print;} } } - # returns 0 if all entries in @target_list are unique. 1 if not. sub check_unique (@target_list){ my @uniqu; @@ -192,13 +198,14 @@ sub unlock { sub cmdline { %optctl = (); # getopts("e:hp:", \%option); - &GetOptions("e=s", "h", "p=s", \@pattern); + &GetOptions("e=s", "h", "p=s", \@pattern, "f=s"); &GetOptions(\%optctl, "e"); &help if $opt_h; } sub help { + $opt_h = 1; # just get rid of that stupid message from -w print << "EOT"; This is a little script to make renaming large quantities of files easy. @@ -208,8 +215,8 @@ environment variable. Which in turn can be overridden with the -e option. At the moment it takes the following options: -h this help message --e "editor" invoke with this editor --p "pattern" use a pattern to edit +-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 EOT