Skip to content

Instantly share code, notes, and snippets.

@dodok1
Created January 17, 2013 11:42
Show Gist options
  • Save dodok1/4555395 to your computer and use it in GitHub Desktop.
Save dodok1/4555395 to your computer and use it in GitHub Desktop.
script to count colours in hierarchy of XPM files
def p = ~/.*\.pm/ // pattern for files
def c = /". c ([0-9A-Za-z#]+)",/ // pattern for colour definition
def count = [:] // count of colours
// recursing into current directory
new File(".").eachDirRecurse { d->
d.eachFileMatch(p) { f->
f.eachLine { l->
m = (l =~ c)
if (m.matches()) count[m[0][1]] = count.containsKey(m[0][1]) ? count[m[0][1]]+1 : 1
}
}
}
println count
println count.size()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment