Delete Folders

R

Rich Bogle

Is there a better way to delete folders than this?

$deletefolder = $compresspath . "/" . $folderlist;
unlink glob "$deletefolder/* $deletefolder/.*";
rmdir $deletefolder;
 
P

Paul Lalli

Is there a better way to delete folders than this?

$deletefolder = $compresspath . "/" . $folderlist;
unlink glob "$deletefolder/* $deletefolder/.*";
rmdir $deletefolder;

I could be wrong, but wouldn't this only remove all files actually in
$deletefolder, and none of the files in any of its subdirectories? It
would therefore not actually delete the directory.

A better option is File::path::rmtree(), which I believe is in the
standard distribution.

perldoc File::path for more info

Paul Lalli
 
P

Paul Lalli

\rm -rf directory_name

That command is _extremely_ dangerous. A single
mistake can delete most or all of your directories
and contained files.

Not to mention that it's unix-specific. The OP is calling directories
'folers', which often indicates they're working on a Windows platform.

Not especially what I'd call a 'better way'.

Paul Lalli
 
P

Paul Lalli

"folders"

Unix, Linux, OS/2, Windows, DOS, folders are directories.

Do you enjoy getting into flame wars about pointless and off-topic
discussions? I don't remember ever hearing the term 'folders' until
Windows started using little file-folder icons for directories in the
Program Manager of Win 3.0. I will freely admit in this case that other
OSs might have used that term previously, as I was rather unfamiliar with
Unix in those days.. Note however, that I said "often indicates" - as in,
"it has been my experience that". If your experience is different, so be
it.
"Not to mention...."

Why did you mention this?

Please learn generic English phrases. You clearly don't understand the
basics.
Oxymoron, yes?

Please consider purchasing a dictionary. You clearly don't understand the
definition of this word, as there was no oxymoron anywhere in this thread.
deltree /y is equally dangerous under MSDOS.

Which is exactly why it, along with rm -rf, should not have been mentioned
in a response to a post asking for "a better way"
Any other specific system commands you wish to use
for critique? Perhaps this is another one of those
"a whole number is decimal number" thoughts of yours?

Which you still haven't adequately responded too, after having the
dictionary definition displayed for you, flat out contradicting your
definition. But that's another thread entirely.

Not to mention sarcasm.

Once again, your use of this phrase indicates your total lacking of
understanding. I reiterate my second point above.


Paul Lalli
 
S

Sherm Pendley

Purl said:
deltree /y is equally dangerous under MSDOS.

I was going to mention that, but it doesn't exist in XP. I wonder when that
happened?

FWIW, I agree with you this time. What's the point in writing a whole pile
of Perl to do something a single system() call could do equally well?

sherm--
 
R

Rich Bogle

Rich Bogle said:
Is there a better way to delete folders than this?

$deletefolder = $compresspath . "/" . $folderlist;
unlink glob "$deletefolder/* $deletefolder/.*";
rmdir $deletefolder;

rmtree looks like a winner to me.

Thanks Paul.
 
P

Paul Lalli

I was going to mention that, but it doesn't exist in XP. I wonder when that
happened?

FWIW, I agree with you this time. What's the point in writing a whole pile
of Perl to do something a single system() call could do equally well?

Because a system() call can't do it equally well, for one - it would
require a code change to move between platforms. Also, it was ambiguous
in the original post as to whether this was the only task required
of the program, or if this was simply one component of a larger picture.

Paul Lalli
 
P

Paul Lalli

Previously you adamantly claimed the originating
author is using a Windows system, although you
did not specify which Windows system. Maybe 3.x?

Now you are claiming ambiguity.

My goodness!

This is what happens when you deliberately
post troll articles in this group; humiliation.

Do you honestly think snipping the relevant part of a post will disable
people from figuring out what really happened? They can read the
originals themselves, you know. You would make one hell of a TV news
journalist, however.

The piece you helpfully snipped here was:
Also, it was ambiguous in the original post as to whether this was the
only task required of the program, or if this was simply one component
of a larger picture.

Explain to me what that has to do with the operating system the OP is
using?
 
J

Jim Cochrane

Do you enjoy getting into flame wars about pointless and off-topic
discussions? I don't remember ever hearing the term 'folders' until
Windows started using little file-folder icons for directories in the
Program Manager of Win 3.0. I will freely admit in this case that other
OSs might have used that term previously, as I was rather unfamiliar with
Unix in those days.. Note however, that I said "often indicates" - as in,
"it has been my experience that". If your experience is different, so be
it.

I believe I first encountered the term "folder" while using the GEM desktop
environment on the Atari OS on an Atari ST in the late 1980s :)
 
P

Peter J. Acklam

Purl Gurl said:
I should correct my syntax.

deltree directory_name /y

I didn't know this is missing under Win XP systems.

As NT5 systems "progress" MSDOS is being stripped out. You
might be able to add this back in. I know you can add a lot of
DOS features back in by downloading DOS 6.22 and adding those
features you want.

Installing the ancient DOS 6.22 is certainly not a good solution.
The solution is to use the right command: "rmdir" or "del."

rmdir /s /q DIR
del /s /q /f DIR

Peter
 
M

Mark Clements

Purl said:
Inherently, there also significant challenges, using Perl,
to find a selected system program and which directory
path separators to use for a system call. Ping!


if (-x "c:/windows/ping.exe")
{ $ping = "c:\\windows\\ping.exe"; }
elsif ( -x "/bin/ping")
{ $ping = "/bin/ping"; }
This cries out for a loop.
my @pingLocations = qw(/bin/ping /usr/sbin/ping);
my ($ping) = grep { -x $_ } @pingLocations;
print $ping;

or something, or you could just rely on the path.

Mark
 
P

Peter J. Acklam

Purl Gurl said:
You are practicing deliberate deceit.

I did not state reinstallation of DOS files under
NT is a solution to the originating author's task.

I never said you stated so either. You have been here so long,
and you don't seem to have changed a bit.

Peter
 
J

John W. Kennedy

GreenLight said:
There was never any "MSDOS" in Windows NT to "strip out". There is a
command interpreter, that doesn't mean that it is MSDOS.

Actually, there are two command interpreters, COMMAND.COM, essentially
the DOS command interpreter, and CMD.EXE, the native NT interpreter.

--
John W. Kennedy
"Those in the seat of power oft forget their failings and seek only the
obeisance of others! Thus is bad government born! Hold in your heart
that you and the people are one, human beings all, and good government
shall arise of its own accord! Such is the path of virtue!"
-- Kazuo Koike. "Lone Wolf and Cub: Thirteen Strings" (tr. Dana Lewis)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top