Count items in a component programmatically
Accepted answer
http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html
Note, walking the tree in a component in the repository workspace allows counting and does not require loading the content to disc.