Last change
on this file since 29661 was 29661, checked in by jmt12, 9 years ago |
A helper script to clean-up the bogus directories sometimes created by Greenstone when building VLDLs... directories with so many files inside that they can't easily be deleted
|
-
Property svn:executable
set to
*
|
File size:
1.2 KB
|
Line | |
---|
1 | #!/usr/bin/perl
|
---|
2 |
|
---|
3 | use strict;
|
---|
4 | use warnings;
|
---|
5 |
|
---|
6 | use POSIX qw(floor);
|
---|
7 |
|
---|
8 | print "\n===== Deletinator =====\n";
|
---|
9 | print "For deleting directories whose contents are too numerous for regular\n";
|
---|
10 | print "'rm' to delete without help and taking over the tri-state area. \n";
|
---|
11 | print "Used when you see:\n";
|
---|
12 | print "bash: /bin/rm: Argument list too long\n";
|
---|
13 | print "Run 'du' to generate a list of files/directories to nuke, then feed\n";
|
---|
14 | print "to thisinator.\n";
|
---|
15 | print "=======================\n\n";
|
---|
16 |
|
---|
17 | if (!defined $ARGV[0] || !-f $ARGV[0])
|
---|
18 | {
|
---|
19 | print "Usage: deletinator.pl <filelist>\n\n";
|
---|
20 | }
|
---|
21 | else
|
---|
22 | {
|
---|
23 | my $filename = $ARGV[0];
|
---|
24 |
|
---|
25 | my $total_filesize = -s $filename;
|
---|
26 | if (open(FIN, '<:utf8', $filename))
|
---|
27 | {
|
---|
28 | my $read_so_far = 0;
|
---|
29 | my $line = '';
|
---|
30 | while ($line = <FIN>)
|
---|
31 | {
|
---|
32 | if ($line =~ /([\d\.GMKB]+)\s+(.*)/)
|
---|
33 | {
|
---|
34 | my $path = './' . $2;
|
---|
35 | $read_so_far += length($line);
|
---|
36 | print 'Deleting "' . $path . '" ';
|
---|
37 | `rmdir $path`;
|
---|
38 | my $progress = 100 * ($read_so_far / $total_filesize);
|
---|
39 | print 'Done [' . floor($progress) . "%]\n";
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
43 | else
|
---|
44 | {
|
---|
45 | print "Error! Failed to open file for reading: " . $filename . "\n";
|
---|
46 | }
|
---|
47 | }
|
---|
48 | print "Complete!\n\n";
|
---|
49 |
|
---|
50 | exit;
|
---|
51 | 1;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.