Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Delete Folders

Reply
Thread Tools

Delete Folders

 
 
Rich Bogle
Guest
Posts: n/a
 
      04-28-2004
Is there a better way to delete folders than this?

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


 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      04-28-2004
On Wed, 28 Apr 2004, Rich Bogle wrote:

> 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:ath::rmtree(), which I believe is in the
standard distribution.

perldoc File:ath for more info

Paul Lalli
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      04-28-2004
On Wed, 28 Apr 2004, Purl Gurl wrote:

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

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

>
>
> \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
 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      04-28-2004
On Wed, 28 Apr 2004, Purl Gurl wrote:

> Paul Lalli wrote:
>
> > Purl Gurl wrote:
> > > Rich Bogle wrote:

>
> > > > Is there a better way to delete folders than this?

>
> > > \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.

>
>
> "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
 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      04-28-2004
Purl Gurl wrote:

> 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--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
Rich Bogle
Guest
Posts: n/a
 
      04-28-2004
"Rich Bogle" <(E-Mail Removed)> wrote in message
news:c6oth0$2cvp$(E-Mail Removed)...
> 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.


 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      04-28-2004
On Wed, 28 Apr 2004, Sherm Pendley wrote:

> Purl Gurl wrote:
>
> > 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?


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
 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      04-28-2004
On Wed, 28 Apr 2004, Purl Gurl wrote:

> Paul Lalli wrote:
>
> > Sherm Pendley wrote:
> > > Purl Gurl wrote:

>
> (snipped)
>
> > Also, it was ambiguous in the original post...

>
> 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?
 
Reply With Quote
 
Jim Cochrane
Guest
Posts: n/a
 
      04-28-2004
In article <(E-Mail Removed)>, Paul Lalli wrote:
> On Wed, 28 Apr 2004, Purl Gurl wrote:
>
>> Paul Lalli wrote:
>>
>> > Purl Gurl wrote:
>> > ...

>> "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.


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

--
Jim Cochrane; http://www.velocityreviews.com/forums/(E-Mail Removed)
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
 
Reply With Quote
 
Peter J. Acklam
Guest
Posts: n/a
 
      04-29-2004
Purl Gurl <(E-Mail Removed)> wrote:

> 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

--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((??:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
zipping files folders and sub folders w/ winzip or winrar Mike Computer Support 5 03-28-2008 09:10 PM
Desktop accesses laptop and reads folders but Laptop only accesses/opens Desktop but cannot read folders, access is denied onclejon Wireless Networking 3 11-01-2006 10:50 PM
NOTE: Storage on small folders, large folders, or one folder Pennywise@DerryMaine.Gov Computer Support 1 06-24-2006 09:09 AM
Can't delete those folders... Themistocles Firefox 1 08-07-2005 10:14 PM
Syncing POP folders with IMAP folders Rich Computer Support 1 02-12-2004 09:36 PM



Advertisments