Pronunciation / adjective
Bringing something good and unforseen.
    Skip Navigation Links > Tech Blog
   

Windows Powershell - Get File Count and Get Lines of Code Count



 

  1/18/2012 9:18:37 AM

Windows Powershell - Get File Count and Get Lines of Code Count

Permalink

Windows Powershell - Get File Count and Get Lines of Code Count

I recently had to estimate how many files were contained in a large solution. Even harder, I was asked for how many lines of code the application contained. Windows powershell to the rescue!


Windows PowerShell Get File Count:
(Get-ChildItem "C:\[Code Location]" -force -recurse).Count
Windows Powershell Get File Count

To get a line count first navigate to the directory in question via: cd [dir]

Windows PowerShell Get Line Count:
(dir -include *.vb, *.cs, *.xsd, *.mdf, *.xml, *.xslt, *.cd, *.js, *.vbs, *.wsf, *.config, *.resx, *.ico, *.rpt, *.txt, *.apsx, *.asax, *.ashx, *.htm, *.html, *.css, *.sitemap, *.skin, *.browser, *.disco, *.ascx -recurse | select-string .).Count
Windows Powershell Get Line Count

Windows PowerShell is a powerful tool in any programmer's arsenal. The next time you have a task to perform and are looking for a tool to do it with give the task name combined with Windows PowerShell a try in google.

Here are some great Windows PowerShell resources:
Scripting with Windows PowerShell
Automating IT Tasks with Windows PowerShell Overview
Windows PowerShell SDK
PowerShell Scripts, Tips, Expert Advice & Training, Forums, and Resources

<January 2012>
SuMoTuWeThFrSa
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234


Microsoft Certified Professional   © 2017 Fortunate.  All rights reserved.
contact: justin@aboutfortunate.com