From: Chris Morris Date: 2003-10-08T22:16:02+09:00 Subject: Re: How to delete read-only files with Ruby commands Gavin Sinclair wrote: > require 'fileutils' > > FileUtils.rm_rf(directory) # trash a directory tree > FileUtils.cp(src, dest, :force => true) # copy over a RO file > >These use Unix names, but I imagine it will work on Windows. > Looks like it will (remove_file is ultimately called by rm_rf and variants...) def remove_file( fname, force = false ) #:nodoc: first_time_p = true begin File.unlink fname rescue Errno::ENOENT raise unless force rescue if first_time_p # try once more for Windows first_time_p = false File.chmod 0777, fname retry end raise end end A slightly more direct version, which I know is good for Windows, but not verified on *nix[1]: files.each do |file| # make writable to allow deletion File.chmod(0644, file) File.delete(file) end [1] from http://www.clabs.org/dl/clutil/ -- Chris http://clabs.org/blogki