source: gs2-extensions/parallel-building/trunk/src/bin/script/deletinator.pl@ 29661

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
3use strict;
4use warnings;
5
6use POSIX qw(floor);
7
8print "\n===== Deletinator =====\n";
9print "For deleting directories whose contents are too numerous for regular\n";
10print "'rm' to delete without help and taking over the tri-state area. \n";
11print "Used when you see:\n";
12print "bash: /bin/rm: Argument list too long\n";
13print "Run 'du' to generate a list of files/directories to nuke, then feed\n";
14print "to thisinator.\n";
15print "=======================\n\n";
16
17if (!defined $ARGV[0] || !-f $ARGV[0])
18{
19 print "Usage: deletinator.pl <filelist>\n\n";
20}
21else
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}
48print "Complete!\n\n";
49
50exit;
511;
Note: See TracBrowser for help on using the repository browser.