From: Robert Klemme Date: 2006-02-19T19:43:29+09:00 Subject: Re: Removing files in directtories John Maclean wrote: > Almost there... I've included line 7 as I'd like to be able to remove > files from a directory using code blocks. Commented it out for now > until I can work out how it's done. Suggestions appreciated. > > #!/usr/bin/ruby -w > def back_up > backdir = ENV["HOME"] + "/foo/" > puts "about to backup some files and tar them into ~/foo" > puts "listing data in ~/foo" > Dir.foreach(backdir) {|file_names| > # File.delete("#{backdir}" + file_names) > puts File.directory? > file_names } > end > back_up I'm not sure what you want, but you might want to consider this: printing: ruby -r find -e 'Find.find( File.join( ENV["HOME"], "foo" ) ) {|f| puts f}' deletion: ruby -r fileutils -e 'FileUtils.rm_rf( File.join( ENV["HOME"], "foo" ) )' Kind regards robert