LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » PC / PC Tips / PC Tricks » Count All Lines Of Codes, Characters, Words In A Directory Recursively On Windows

Count All Lines Of Codes, Characters, Words In A Directory Recursively On Windows

Count-All-Lines-Of-Codes,-Characters,-Words-In-A-Directory-Recursively-On-Windows
I’d like a quick way to determine the number of lines in all of the files in a directory tree, for files of a given extension. Is there any good out of the box way to do this? There are many built-in commands in Linux, Bash, Unix but what’s in Windows?

We are sure that you have the same question. Let us re-write your question as follows.

Do you want to know how to count all lines of codes, characters, words in a directory recursively on windows then here is a simple line of command without any third party plugin/code using windows Powershell.

Measure-Object:

Module: Microsoft.PowerShell.Utility

Calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files of text.

Measure-Object in PowerShell is used to measure the property of the command. There are various measurement parameters are available. For example, Average, Count, sum, maximum, minimum, and more.

Count All Lines Of Codes, Characters, Words In A Directory Recursively On Windows PowerShell:

Step 1: Open PowerShell

Step 2: Go to that main director in PowerShell where you want to count all inner file/folders data.

Recommended For You:
Top 10 Free Online Scanners To Kick Virus Out Of Your System

Step 3: Then select the below code as per your desire.

Count All Words:

dir -Recurse *.php | Get-Content | Measure-Object -Word

Count All Characters:

dir -Recurse *.php | Get-Content | Measure-Object -Character

Count All Lines Of Codes:

dir -Recurse *.php | Get-Content | Measure-Object -Line

Count All Lines Of Codes Characters, Words:

dir -Recurse *.php | Get-Content | Measure-Object -Line -Word -Character

Step 3: And the output will be like below.

Lines Words Characters Property
----- ----- ---------- --------
  168    28        100

Customization:

You can do many things with this code. Want to know more, just go How to use Measure-Object in PowerShell?.

Troubleshooting the Errors

Do it with concentration and patience. Check your alls steps and again and all codes or scripts. If you find any error you can contact us anytime via comment or better via email, We are always here to help you.

Final Words:

That’s all we have. We hope that you liked this article. If you have any problem with this code in your file then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us or If you have any doubts and problems please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave your precious feedback in our comment form below. Happy development, See you in the next article.

Recommended For You:
Top 10 & Common Reasons MacBook Crash On Startup

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *