I would like to delete a directory. In this directory are other
directories an files. So I have to delete this subdirectories an files
at first. Now I search a good solution to solve this problem. My first
idea was to look in the given directory and if there are subdirectories
to look in this directories… Is this the right way? Is there a ready
function for this little problem? Or has anybody written a function for it?
On Sat, 17 Apr 2004 21:53:48 +0200, Dirk Einecke wrote:
I would like to delete a directory. In this directory are other
directories an files. So I have to delete this subdirectories an files
at first. Now I search a good solution to solve this problem. My first
idea was to look in the given directory and if there are subdirectories
to look in this directories… Is this the right way? Is there a ready
function for this little problem? Or has anybody written a function for it?
On Sat, 17 Apr 2004 20:53:48 +0200, Dirk Einecke wrote:
Hi.
I would like to delete a directory. In this directory are other
directories an files. So I have to delete this subdirectories an files
at first. Now I search a good solution to solve this problem. My first
idea was to look in the given directory and if there are subdirectories
to look in this directories… Is this the right way? Is there a ready
function for this little problem? Or has anybody written a function for
it?
I would like to delete a directory. In this directory are other
directories an files. So I have to delete this subdirectories an files
at first. Now I search a good solution to solve this problem. My first
idea was to look in the given directory and if there are subdirectories
to look in this directories… Is this the right way? Is there a ready
function for this little problem? Or has anybody written a function for it?
I would like to delete a directory. In this directory are other
directories an files. So I have to delete this subdirectories an files
at first. Now I search a good solution to solve this problem. My first
idea was to look in the given directory and if there are
subdirectories
to look in this directories… Is this the right way? Is there a ready
function for this little problem? Or has anybody written a function
for
it?
greetings
Dirk Einecke
rm -rf directory
Another one liner would be:
Dir[File.join(dir, ‘**’, ‘*’)].reverse.each {|f| (File.directory? ? Dir :
File).delete f}
Note: this one is portable also.
robert
···
On Sat, 17 Apr 2004 20:53:48 +0200, Dirk Einecke wrote:
You could update to Ruby 1.8+ where fileutils.rb is a standard module.
If that doesn’t work you can simply put a copy of fileutils.rb from a
recent distribution into your working script directory and include it
from there. No need to “install” it.
And if for some reason that isn’t possible, then you can always just
copy the code straight from the module into your script. In this case it
looks like you’d need to copy in less than 25 lines of code for the
rm_rf command and the rm_r command. The only time I wouldn’t do this is
if there were license concerns. In any case, the fileutils.rb module has
a great example of how to do this.
You could update to Ruby 1.8+ where fileutils.rb is a standard module.
That’s not possible to because Ruby is running on the server of my ISP.
If that doesn’t work you can simply put a copy of fileutils.rb from a
recent distribution into your working script directory and include it
from there. No need to “install” it.
Okay. I will try this. But where can I get the newest version? I found
this two pages:
… and click download. Then just stick it in the same directory as the
other files, and viola!
cheers,
–Mark
···
On Apr 17, 2004, at 1:54 PM, Dirk Einecke wrote:
If that doesn’t work you can simply put a copy of fileutils.rb from a
recent distribution into your working script directory and include it
from there. No need to “install” it.
Okay. I will try this. But where can I get the newest version?