![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-11 12:43 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » File Line Count Statistics |
| Printable Version 1,081 / 8 |
| Floor1 boy7470 | Posted 2009-03-02 01:43 |
| 新手上路 Posts 4 Credits 4 | |
|
I have several hundred files with the extensions: xls, xlsx, txt. Now I want to count the number of lines in each file (blank lines not included). These files are in a folder and its subfolders, and I also want the directories listed. Does anyone have a good way to solve this? Thanks in advance!!!!
|
|
| Floor2 netbenton | Posted 2009-03-02 02:03 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
::Drag a directory onto this batch file, or specify a directory in %1, otherwise process the current directory
::The filenames of the specified types under this directory and all subdirectories, together with their line counts, are saved as a list in list.txt @echo off set dir= set "dir=%~dp1\" for /f "delims=" %%a in ('dir /b /s /a-d %dir% *.xls *.xls *.txt') do ( set/a n=0 for /f %%b in ('type "%%a"') do set/a n+=1 call echo.%%a has %%n%% lines )>%temp%\list.txt move %temp%\list.txt %dir%list.txt |
|
| Floor3 boy7470 | Posted 2009-03-02 02:59 |
| 新手上路 Posts 4 Credits 4 | |
|
I ran it according to the code given in reply #2,
but it doesn't work. I tried it and there was no response for a long time. My filenames contain Chinese characters. Why is that? |
|
| Floor4 boy7470 | Posted 2009-03-02 04:13 |
| 新手上路 Posts 4 Credits 4 | |
|
Why is nobody answering? Doesn't anyone know how to do this?
|
|
| Floor5 slore | Posted 2009-03-02 04:57 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
| Floor6 netbenton | Posted 2009-03-02 07:47 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
Your files aren't plain text, right!?
If that's the case, better not use BAT. At least I can't do it. |
|
| Floor7 boy7470 | Posted 2009-03-02 08:46 |
| 新手上路 Posts 4 Credits 4 | |
|
Yes, not all of my files are text files. There are also .xls and .xlsx files. Is there any other way?
|
|
| Floor8 netbenton | Posted 2009-03-02 09:43 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
No
|
|
| Floor9 yishanju | Posted 2009-03-02 20:00 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
Originally posted by boy7470 at 2009-3-2 08:46: For office documents you should consider using VBS, VBA, or python |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |