Gossamer Forum
Home : Products : Others : Fileman :

Remove (delete) Full Directories

Quote Reply
Remove (delete) Full Directories
Would someone please explain the portion of the fileman script I must remove in order to delete a directory which contains files?

Currently, any attempt in deleting a directory which contains a file returns the following error message:

"Directory was not removed. Check that the directory is empty".

I'd like to edit the script and remove this safety feature, so that I may delete an entire directory full of files, without having to delete each single file within the directory beforehand.

Please email me if you can help, or post a reply. Greatly appreciate any and all help!


Please remove -NOSPAM- from the above address for email correspondance!
Quote Reply
Re: Remove (delete) Full Directories In reply to
Find this...

Code:
sub removedir {
# -----------------------------------------------------
# Removes a directory.
#
my ($root, $new) = @_;
my ($fulldir);

# Make sure we have a directory name to delete.
(!$new) and return "Remove Directory: No directory name was entered!";

# Get the full directory.
($root =~ m,/$,) ? ($fulldir = "$root$new") : ($fulldir = "$root/$new");

# Then remove if possible.
if (!&exists($fulldir)) {
return "Remove Directory: '$new' does not exist.";
}
else {
rmdir($fulldir) ?
return "Remove Directory: '$new' has been removed." :
return "Remove Directory: '$new' was <B>not</B> removed. Check that the directory is empty.";
}
}
This should work.......

Code:
if (!&exists($fulldir)) {
return "Remove Directory: '$new' does not exist.";
}
else {
`rm -r $fulldir`;
}
}
Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Remove (delete) Full Directories In reply to
Thank you Paul, for that super-speedy reply!

As an aside, I'm extremely soaked behind the ears with regards to editing perl. I can barely understand the source code, no less remove portions of it that *might be* what I'm looking for :-)

As one who uses "WebTV", and still makes copies of everything I edit beforehand, I'm sure you can appreciate my postition!

Thanks again!

Please remove -NOSPAM- from the above address for email correspondance!
Quote Reply
Re: Remove (delete) Full Directories In reply to
No problem.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Remove (delete) Full Directories In reply to
Well it worked fine, thank you. The only thing I noticed now is that I lost the "Action taken" return message. Any ideas how I might incorporate that back into the script?

Big Smiley :)



Please remove -NOSPAM- from the above address for email correspondance!
Quote Reply
Re: Remove (delete) Full Directories In reply to
Oh sorry I forgot that.....

Code:
if (!&exists($fulldir)) {
return "Remove Directory: '$new' does not exist.";
} else {
`rm -r $fulldir`;
return "$fulldir removed successfully.";
}
}

You could try this too....

Code:
if (!&exists($fulldir)) {
return "Remove Directory: '$new' does not exist.";
} else {
`rm -r $fulldir` or "Could not remove $fulldir : $!" and return;
return "$fulldir removed successfully.";
}
}





Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Remove (delete) Full Directories In reply to
Worked perfectly and flawlessly, Paul. Thank you!

Just so you know, this is an original Fileman that's been through a few other scripters before it got to me, hence those comment areas are no longer included, and there are many modifications each subsequent user made to personalize the editor area and file manager area to their liking and preferences.

The basic core is still Gossamer Threads however.

Thanks again for your super-speedy help!


Please remove -NOSPAM- from the above address for email correspondance!