Get linecounts from multiple files

July 10, 2009 at 09:11:06
Specs: Windows XP
hey experts,

I want to know if is there any way can I get the batch file code which count the number of records from multiple files from particular location and give me output in excel with column says filename, no of records

Appreciate your help

See More: Get linecounts from multiple files

Report •

July 10, 2009 at 12:57:57
If the files are text files, that is possible, stated the result is a .csv file you can then import into excel.

The following script is an example

:: FILECNT.BAT Usage: filecnt Folder_Name
@echo off > output.csv
pushd %*
for %%j in (*.txt) do (
  for /F  %%k in ('type "%%j" ^| find /V /C ""') do echo.%%j,%%k>> output.csv
:: End_Of_Batch

Report •

July 23, 2009 at 11:50:06
hey thanx a lot IVO,
As I seen couple of post from u here, I Was expectig u to answer.....

I Appreciate your help.

Report •

July 23, 2009 at 19:20:00
you can eliminate the outer for loop. more efficient this way.
for /F "tokens=2*"  %%l in ('find /V /C "" *.txt') do echo %%l%%m

GNU win32 packages | Gawk

Report •

Related Solutions

July 29, 2009 at 07:41:36
thanx a lot ghostdog

your solution works more efficient ,
Although first solution also does work, but sometimes it says unable to read file at first time and when I run it again it able to read files.So I was bit confused and then I tried second solution posted by you, it works better as I expected.

I appreciate for your help guys............
Thanx again

Report •

Ask Question