Created
January 17, 2013 11:42
-
-
Save dodok1/4555395 to your computer and use it in GitHub Desktop.
script to count colours in hierarchy of XPM files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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