/usr/bin/bins_cleanupgallery is in bins 1.1.29-16.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #!/usr/bin/perl
#
# CleanupGallery v0.1 for BINS
# Copyright (C) 2003 by Jochen Schaeuble <psionic@psionic.de>
#
# $Id: bins_cleanupgallery,v 1.3 2003/04/08 18:29:46 jerome Exp $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
use File::Glob ':glob';
@knownImageExtentions = ("jpg", "jpeg", "gif", "png", "tiff",
"bmp", "tga", "ps", "eps", "fit", "pcx",
"miff", "pix", "pnm", "rgb", "im1", "xcf",
"xwd", "xpm", "avs", "dcm", "dcx", "dib",
"dps", "dpx", "epdf", "epi", "ept", "fpx",
"icb", "mat", "mtv", "pbm", "pcd", "pct",
"pdb", "ppm", "ptif", "pwp", "ras", "thm",
);
$imageExts = join('|', @knownImageExtentions);
@webFormats = ("jpg", "jpeg", "gif", "png");
$webExts = join('|', @webFormats);
sub ProcessDir
{
local *DIR;
(local $curdir, local $dstdir, local $srcdir) = @_;
opendir(DIR, "$dstdir/$curdir");
while ($file = readdir(DIR)) {
$file = "$curdir/$file";
if (-d "$dstdir/$file" && $file !~ m/\.\.?$/ && $file !~ m/static\.\w*$/) {
if (-d "$srcdir/$file") {
# Directory exists in src and dest, process it
&ProcessDir($file, $dstdir, $srcdir);
} else {
# Directory only available in dest remove it
print "## Removing dir: $dstdir/$file\n";
`rm -Ri \"$dstdir/$file\"`;
}
} elsif ((-f "$dstdir/$file" || -l "$dstdir/$file") &&
$file =~ m/.*\.($webExts)$/i) {
my @srcfiles = bsd_glob("$srcdir/$curdir/*",
GLOB_NOCASE |
GLOB_QUOTE |
GLOB_TILDE);
$filefound = 0;
FILESEARCH:
foreach $curfile (@srcfiles) {
# remove trailing .xml
if ($curfile =~ m/.*\.xml$/i) {
$curfile =~ s/(.*)\.xml$/$1/i;
}
# remove file extension
$curfile =~ s/.*\/([^\/]*)\.($imageExts)$/$1/i;
if (($curfile ne "") && ($file =~ m/$curfile.*\.($webExts)$/i)) {
$filefound = 1;
last FILESEARCH;
}
}
if ($filefound == 0) {
$file =~ s/(.*)_\w+\.($webExts)$/$1/i;
print "## Removing file: $dstdir/$file*\n";
`rm -v \"$dstdir/$file\"*`;
}
}
}
closedir(DIR)
}
sub usage
{
print "CleanupGallery v0.1 (c) 2003 by Jochen Schaeuble <psionic\@psionic.de\n";
print "\n";
print "This is free software with ABSOLUTELY NO WARRANTY.\n";
print "See COPYING file for details.\n\n";
print "Usage:\n\n";
print "cleanupgallery <Gallery Source Directory> <Destination Directory>\n";
print "\n";
exit(0);
}
if ($#ARGV != 1 || !-d $ARGV[0] || !-d $ARGV[1]) {
&usage;
}
($srcdir, $dstdir) = @ARGV;
ProcessDir("", $dstdir, $srcdir);
|