Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Get linecounts from multiple files
Name: hgediya Date: July 10, 2009 at 09:11:06 Pacific OS: Windows XP Subcategory: Batch
Comment:
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
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
)
popd
:: End_Of_Batch
0
Response Number 2
Name: hgediya Date: July 23, 2009 at 11:50:06 Pacific
Reply:
hey thanx a lot IVO, As I seen couple of post from u here, I Was expectig u to answer.....
I Appreciate your help.
0
Response Number 3
Name: ghostdog Date: July 23, 2009 at 19:20:00 Pacific
Reply:
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
.....
Name: hgediya Date: July 29, 2009 at 07:41:36 Pacific
Reply:
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
Summary: I need to get from a file only the first line and to write it into other file-only using DOS commands.Till now I have managed to get the entire content of the file using a command like: FOR /F "usebac...
Summary: I want to copy files from multiple directories without creating the directory tree. XCOPY /S gets all the files I need, but creates the tree as well. I have 100 subdirectories and every folder contain...
Summary: Guys I'm looking for a bit of code which would allow me to extract rows 3 to 34 from multiple csv files (over 100) and place the rows into one large csv for parsing.The csv files are exactly the same ...