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.
1
2 def deleteDir(dir)
3 puts "cd #{dir}"
4 Dir.chdir(dir)
5 Dir.foreach(dir) do |file|
6 if file != "." and file != ".."
7 if File.directory?(file)
8 deleteDir("#{dir}/#{file}")
9 else
10 puts "delete file #{file}"
11 File.delete(file)
12 end
13 end
14 end
15 Dir.chdir("..")
16 puts "delete directory #{dir}"
17 Dir.delete(dir)
18 end
19
20 def processDir(dir)
21
22 Dir.chdir(dir)
23 Dir.foreach(dir) do |file|
24 if File.directory?(file)
25 if file == "CVS"
26 puts "Deleting directory #{dir}/#{file}"
27 deleteDir("#{dir}/#{file}")
28 elsif file != "." and file != ".."
29 processDir("#{dir}/#{file}")
30 end
31 end
32 end
33 Dir.chdir("..")
34 end
35
36 puts "Working directory: #{Dir.pwd}"
37 processDir(Dir.pwd)