Here's a simple Ruby script to remove CVS directories. Useful if you move a large codebase from one repository to another. To use it just go to the root directory where you want to start the deleting and run the script. The script will start in the current working directory and apply the removal recursively.
def deleteDir(dir)
puts "cd #{dir}"
Dir.chdir(dir)
Dir.foreach(dir) do |file|
if file != "." and file != ".."
if File.directory?(file)
deleteDir("#{dir}/#{file}")
else
puts "delete file #{file}"
File.delete(file)
end
end
end
Dir.chdir("..")
puts "delete directory #{dir}"
Dir.delete(dir)
end
def processDir(dir)
Dir.chdir(dir)
Dir.foreach(dir) do |file|
if File.directory?(file)
if file == "CVS"
puts "Deleting directory #{dir}/#{file}"
deleteDir("#{dir}/#{file}")
elsif file != "." and file != ".."
processDir("#{dir}/#{file}")
end
end
end
Dir.chdir("..")
end
puts "Working directory: #{Dir.pwd}"
processDir(Dir.pwd)