summaryrefslogtreecommitdiffstats
path: root/util/mvdir.pl
blob: 1587b7991e41f36fe24e66a8bd6b76a1da570f07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl
if( !@ARGV ){
    print "usage: mvdir.pl which prefix from_id to_id\n";
    exit;
}

($which, $prefix, $from_id, $to_id) = @ARGV;
$which = 'man/boards' if( $which eq 'man' );

$fromdir = "/scsi$from_id/bbs/$which/$prefix";
$todir = "/scsi$to_id/bbs/$which/$prefix";

if( !-e $fromdir ){
    print "from dir ($fromdir) not found\n";
    exit;
}

mkdir $todir;
chdir $fromdir;
foreach( <*> ){
    next if( /^\./ );
    symlink("$fromdir/$_", "$todir/$_");
    push @dirs, $_;
}

unlink "/home/bbs/$which/$prefix";
symlink($todir, "/home/bbs/$which/$prefix");

foreach( @dirs ){
    printf("processing %-20s (%04d/%04d)\n", $_, ++$index, $#dirs);
    unlink "$todir/$_";
    `mv $fromdir/$_ $todir/$_`;
}

rmdir "$fromdir";