JSI Tip 7276. How can I right-click a file in Windows Explorer and see the number of lines in the file?

I have scripted LineCount.bat to display the number of lines in a text-based (.txt, .csv, .html, etc...) file.

To place it in a Windows Explorer context menu:

1. Create a shortcut to LineCount.bat and rename the shortcut to anything you desire, like LineCount.

2. Move the shortcut to your SendTo folder, "%userprofile%\sendto".

To invoke the LineCount.bat file from Windows Explorer:

1. Right-click a file and press Send To and LineCount.

2. To close the display, press Enter in the CMD window.

LineCount.bat contains:

@echo off
setlocal
for /f %%i in ('find /v /c "" ^ set /p lc=Lines=%lines%
endlocal

NOTE: See tip 4574 » How can I count the number of lines in a file, and/or display the last n lines?


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish