用线数量最多的选择文件 [英] select file with the largest number of lines
本文介绍了用线数量最多的选择文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
据统计行的数量在所有文件,但我需要选择具有行数最多的文件。
It count number of line in all file but i need select the file with the largest number of lines.
for %%a in (*.*) do (
for /f %%b in (' find "" /v /c ^< "%%a" ') do (
echo %%a=%%b
)
)
输出:
的test.txt = 10结果
asdasd.txt = 15结果
asdasd.txt = 20
test.txt=10
asdasd.txt=15
asdasd.txt=20
我需要的输出:结果
asdasd.txt = 20
I need output:
asdasd.txt=20
只有一个文件用线的数量最多
普莱斯帮助。 THX
only one file with the largest number of lines Pleas help. Thx
推荐答案
第一个选项,叫找到
为每个文件,然后解析输出
First option, calling find
for each file and then parsing output
@echo off
setlocal enableextensions enabledelayedexpansion
set "maxLines=0"
set "maxFile="
for %%a in (*.txt) do (
for /f %%b in ('^<"%%a" find /c /v ""') do if %%b gtr !maxLines! (
set "maxLines=%%b"
set "maxFile=%%a"
)
)
echo %maxFile%=%maxLines%
第二个选项调用找到
只有一次和解析输出
@echo off
setlocal enableextensions enabledelayedexpansion
set "maxLines=0"
set "maxFile="
for /f "tokens=* delims=- " %%a in ('find /c /v "" *.txt '
) do for /f "tokens=1,2 delims=:" %%b in ("%%a"
) do if %%c gtr !maxLines! (
for %%d in (%%c) do set "maxLines=%%d"
set "maxFile=%%b"
)
echo %maxFile%=%maxLines%
这篇关于用线数量最多的选择文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文