From: Andrea Fazzi Date: 2007-11-05T16:59:45+09:00 Subject: Re: Delete files in a directory require 'fileutils' def delete(filename) Dir["#{File.dirname(filename)}/*"].each do |file| next if File.basename(file) == File.basename(filename) FileUtils.rm_rf file, :noop => true, :verbose => true end end USAGE: delete 'path/to/file1' Bye. Andrea Il giorno sab, 03/11/2007 alle 19.39 +0900, Oscar Del ben ha scritto: > Hello, this is my first post here, so first i would like to thanks all > the people who works for this site. > > Well, i'm trying to set up a little script that should delete all the > files in a given drectory; the system should work like this: > -I have the name and the path of file = "/Users.....file1" > -from file, i should get the directory (I've used File.dirname(file)) > -from that directory, i should delete all files and sub directories > except from the given file (in this case, file1) > > I'm making confusion when i try to iterare on the files and irectory in > that folder, and i'm scared to make test of deleting files in the system > > Oscar