Ticket #5441: move.diff
File move.diff, 1.6 KB (added by , 16 years ago) |
---|
-
contrib/maintenance/myth.find_orphans.pl
40 40 use DBI; 41 41 use Sys::Hostname; 42 42 use Getopt::Long; 43 43 use File::Copy; 44 44 # 45 45 # options 46 46 # … … 58 58 my $opt_help = 0; 59 59 my $opt_dryrun = 0; 60 60 my $opt_rerecord = 0; 61 61 my $opt_domove = 0; 62 my $opt_destdir = "/tmp"; 62 63 GetOptions( 63 64 'host=s' => \$opt_host, 64 65 'dbhost=s' => \$opt_dbhost, … … 73 74 'debug+' => \$debug, 74 75 'help' => \$opt_help, 75 76 'h' => \$opt_help, 76 'v' => \$opt_help); 77 'v' => \$opt_help, 78 'domove' => \$opt_domove, 79 'destdir=s' => \$opt_destdir); 77 80 78 81 if ($opt_help) { 79 82 print<<EOF … … 92 95 --dodelete delete files with no record (default: don't) 93 96 --dryrun display delete actions without doing them 94 97 --rerecord set db entries to re-record missing files (requires --dodbdelete) 95 98 --domove move files instead of deleting specify destination with --destdir= (default /tmp) 96 99 EOF 97 100 ; 98 101 exit(0); … … 207 210 } 208 211 } 209 212 } 213 if ($opt_domove) { 214 printf STDERR "moving [%s]: %s/%s to %s\n",pretty_filesize($this_filesize),$this_dir,$this_file, $opt_destdir; 215 if (!$opt_dryrun) { 216 move("$this_dir/$this_file",$opt_destdir); 217 if (-f "$this_dir/$this_file") { 218 $errors++; 219 printf "ERROR: Could not move $this_dir/$this_file to $opt_destdir"; 220 } 221 } 222 } 210 223 } else { 211 224 $known_files++; 212 225 $known_size += $this_filesize;