Removing a directory that isn't empty

Discussion in 'Ruby' started by Gabriel Dragffy, Oct 22, 2007.

  1. 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
    Gabriel Dragffy, Oct 22, 2007
    #1
    1. Advertising

  2. Gabriel Dragffy

    Bil Kleb Guest

    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
    Bil Kleb, Oct 22, 2007
    #2
    1. Advertising

  3. Gabriel Dragffy

    Alex Young Guest

    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
    Alex Young, Oct 22, 2007
    #3
  4. Gabriel Dragffy

    Arul hari Guest

    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/.
    Arul hari, Oct 22, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    574
    Dave Thompson
    Feb 14, 2004
  2. Chris  Chiasson
    Replies:
    6
    Views:
    614
    Richard Tobin
    Nov 14, 2006
  3. codeboy
    Replies:
    1
    Views:
    1,557
    Juan T. Llibre
    Jun 8, 2009
  4. happytoday

    Removing empty lines

    happytoday, Jul 21, 2011, in forum: C Programming
    Replies:
    13
    Views:
    1,186
  5. Gordon
    Replies:
    1
    Views:
    220
    nolo contendere
    Apr 14, 2008
Loading...

Share This Page