How to count all the lines of code in a directory recursively on Windows?
You can use Measure-Object
in powershell like this:
PS D:\temp> dir -Recurse *.txt | Get-Content | Measure-Object -Line
Which will return the following:
Lines Words Characters Property
----- ----- ---------- --------
168
To expand on maweeras answer above (sorry not enough rep to comment), you can search for multiple file extensions by passing a comma-delimited array to -Include.
So for example:
dir -Recurse -Include *.ts,*.tsx -Exclude *node_modules* | Get-Content | Measure-Object -Line
The following works in cmd:
for %f in (*.TXT) do find /v /c "" "%f"
Or in a [.bat]:
for %%f in (*.TXT) do find /v /c "" "%%f"