Platinum Partner

Remove CVS Directories With Ruby

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)
    #puts "Processing directory #{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)
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}