Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Additional lines

Hi EEE:


 How do I count the number of lines in a file? I guess when one of my fields in the line is big I am worried if the line is breaking into two, creating additional rows. How can I verify this in the batch? Using a text editor is a bit tricky because they may be counting the lines by different endpoints. I imported the csv file into access and the total rows looked correct whereas in Notepad ++ there were additional lines.

Please help solve thi mystery.
0
LuckyLucks
Asked:
LuckyLucks
  • 2
3 Solutions
 
becraigCommented:
Batch File

@Echo OFF
for /f %%A in ('Find /V /C "" ^< c:\file.txt') do set Count=%%A
echo The file has %Count% lines.
0
 
Bill PrewCommented:
Even easier than that, and this will count blank lines where FOR won't, at a command prompt do:

find /c /v "" filename.txt

~bp
0
 
Paul TomasiCommented:
I prefer the following:

for /f "tokens=3" %%a in ('find /c /v "" filename.csv') do echo %%a Line(s)

Open in new window

0
 
Bill PrewCommented:
Hmmm, why would one want to type more than needed to get the line count Paul?

But if you feel there is a need for that, then the proper way to handle that would be:

for /f %%a in ('find /c /v "" ^<"filename.csv"') do echo %%a Line(s)

Open in new window

This will handle the case correctly where a filename contains spaces, which your approach would have a problem with.

~bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now