Skip to content

Instantly share code, notes, and snippets.

@drasch
Created September 24, 2012 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drasch/3776118 to your computer and use it in GitHub Desktop.
Save drasch/3776118 to your computer and use it in GitHub Desktop.
Count files by extensicount-files-by-extension.rbon
require 'rubygems'
require 'activesupport'
ct = Hash.new(0)
while gets
ma = $_.match %r/\.(\w{2,10})$/
ct[ma[1]] += 1 if ma
end
y ActiveSupport::OrderedHash[ct.sort_by {|k,v| v}].reject {|k,v| v<50}
@drasch
Copy link
Author

drasch commented Sep 24, 2012

Purpose

Count files by certain extensions so I could exclude them in the CtrlP plugin for Vim.

By default, this will show you all extensions with > 50 instances in your tree.

Usage

$ find | ruby count-files-by-extension.rb

@drasch
Copy link
Author

drasch commented Sep 24, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment