2 ###APPNAME: zim-del-directory
4 ###APPDATE: 2008-05-11 14:27:04
6 ###APPDESC: delete zim directory entry
7 ###APPUSAGE: [--test] (directory) [level]
8 #[entry Name] [entry Description] [destination]
9 ###APPEXAMPLE: zim-del-directory Test .test abc.txt
10 ###APPOPTION: --test:No writing will be made
13 #ENV variable MUST be defined somewhere,
14 #FOR perl to search modules from,
17 use lib
$ENV{XR_PERL_MODULE_DIR
};
19 use MyPlace
::Script
::Usage qw
/help_required help_even_empty/;
20 exit 0 if(help_even_empty
($0,@ARGV));
24 if($ARGV[0] eq "--test") {
28 my ($root_d,$level) = @ARGV;
29 $level=32768 unless($level);
31 #my ($edir,$ename,$edesc,$dist) = @ARGV;
35 print STDERR
"\t$str";
42 # $ename =~ s/^.*\///g;
47 ## $eloc =~ s/[ ,\+ ~×]/_/g;
53 # $dist =~ s/\/?$/.txt/;
58 warn "Can't change to $dir!\n";
63 print STDERR
"[Test]unlink $_...\n" foreach(@_);
66 print STDERR
"Unlink $_...\n" foreach(@_);
67 unlink @_ or warn("$!\n");
71 sub deleteDirectory
($) {
79 do_unlink
"$edir.txt" if(-f
"$edir.txt");
80 chdir($edir) or return(error_chdir
($edir));
81 do_unlink
"$edir.txt" if(-f
"$edir.txt");
82 foreach my $file (glob("*")) {
83 next if($file eq ".");
84 next if($file eq "..");
85 if(-d
$file && $level>=0) {
90 do_unlink
"$_.txt" if(-f
"$_.txt");
95 chdir($olddir) or return(error_chdir
($olddir));
98 &deleteDirectory
($root_d);