Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Removing a directory that isn't empty

Reply
Thread Tools

Removing a directory that isn't empty

 
 
Gabriel Dragffy
Guest
Posts: n/a
 
      10-22-2007
What would be the best way to use Dir.rmdir to delete a directory
that isn't empty? I think it would involve performing a recursive
delete, this is trivial in bash, but what about in Ruby?

Many thanks

Gabriel Dragffy

 
Reply With Quote
 
 
 
 
Bil Kleb
Guest
Posts: n/a
 
      10-22-2007
Gabriel Dragffy wrote:
> What would be the best way to use Dir.rmdir to delete a directory that
> isn't empty? I think it would involve performing a recursive delete,
> this is trivial in bash, but what about in Ruby?


I normally use FileUtils for that sort of thing, e.g.,

require 'fileutils'
FileUtils.rm_rf 'directory'

Regards,
--
Bil Kleb
http://nasarb.rubyforge.org
 
Reply With Quote
 
 
 
 
Alex Young
Guest
Posts: n/a
 
      10-22-2007
Gabriel Dragffy wrote:
> What would be the best way to use Dir.rmdir to delete a directory that
> isn't empty? I think it would involve performing a recursive delete,
> this is trivial in bash, but what about in Ruby?
>

FileUtils.rm_rf should do the trick.

--
Alex

 
Reply With Quote
 
Arul hari
Guest
Posts: n/a
 
      10-22-2007
Gabriel Dragffy wrote:
> What would be the best way to use Dir.rmdir to delete a directory
> that isn't empty? I think it would involve performing a recursive
> delete, this is trivial in bash, but what about in Ruby?
>
> Many thanks
>
> Gabriel Dragffy


Dear Friends,
I am having one best idea to removing the empty directory.
You have to remove the directory while checking the directory size.
and also while putting the du -sh itself we can do .It is a easy method
to remove the directory.
Somebody might have asking the question before itself.
Plese you could go and see all the questions.In somewhere you will get
the idea for this.

by
vellingiri.
--
Posted via http://www.ruby-forum.com/.

 
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
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
System.IO.Directory.Delete Throws "the directory is not empty" codeboy ASP .Net 1 06-08-2009 12:08 PM
Recursive delete of directory - Directory not empty error Gordon Javascript 1 04-14-2008 06:28 PM
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
Check if a directory is empty and empty it Marcia Hon C Programming 8 02-14-2004 03:53 AM



Advertisments