本帖最后由 Nsqs 于 2017-1-18 09:10 编辑
方法1- @echo off&setlocal enabledelayedexpansion
- set "ff=收集"
- md "%ff%" 2>nul
- for %%i in ("*.txt")do (set f=%%i
- (for /f "tokens=1,2 delims=:#" %%1 in ('findstr /n "^[\u4e00-\u9fff0]*\ #" "%%i"')do (
- set b=%%2
- set /a s=%%1
- if "%%2"=="视频 " (set /a c1+=1
- call echo %%2#%%c1%%
- call:视频&echo;
- )
- if "%%2"=="音频 " (set /a c2+=1
- call echo %%2#%%c2%%
- call:音频&echo;
- )
- if "%%2"=="菜单 " (set /a c3+=1
- call echo %%2#%%c3%%
- call:菜单&echo;
- )
- ))>%ff%\%ff%_%%~ni.txt
- )
- exit
- :视频
- for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
- set a=%%1
- call set a=%%a: =%%
- for %%3 in (文件格式 画面高度 扫描方式)do (
- if "!a!"=="%%3" echo %%1:%%2&set /a z+=1
- if !z! geq 3 set z=0&goto :eof
- )
- )
- goto :eof
- :音频
- for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
- set a=%%1
- call set a=%%a: =%%
- for %%3 in (文件格式 采样率)do (
- if "!a!"=="%%3" echo %%1:%%2&set /a z+=1
- if !z! geq 2 set z=0&goto :eof
- )
- )
- goto :eof
- :菜单
- for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
- set a=%%1
- call set a=%%a: =%%
- if "!a!"=="服务名" echo %%1:%%2&goto :eof
- )
- goto :eof
复制代码 方法2- @echo off&setlocal enabledelayedexpansion
- set "ff=收集"
- md "%ff%" 2>nul
- set "cl1=视频"
- set "cl2=音频"
- set "cl3=菜单"
- set "ss1=文件格式 画面高度 扫描方式"
- set "ss2=文件格式 采样率"
- set "ss3=服务名"
- for /l %%1 in (1 1 3)do call set "cl%%1=!cl%%1! "
- set "m=%cl1%
- set /a n1=3,n2=2,n3=1
- for %%i in ("*.txt")do (set f=%%i&set /a c=1,x=1
- (for /f "tokens=1,2 delims=:#" %%1 in ('findstr /n "^[\u4e00-\u9fff0]*\ #" "%%i"')do (
- set b=%%2
- set /a s=%%1
- call:d&echo;
- ))>%ff%\%ff%_%%~ni.txt
- )
- exit
- :d
- set /a z+=1
- call echo %%b%%#%%z%%
- call set ss=%%ss!x!%%
- call set n=%%n!x!%%
- if !z! geq 4 (
- set /a x+=1,z=0
- call set m=!cl%%x%%!
- )
- for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
- set a=%%1
- call set a=%%a: =%%
- for %%3 in (%ss%)do (
- if "!a!"=="%%3" echo %%1:%%2&set /a z1+=1
- if !z1! geq %n% set z1=0&goto :eof
- )
- )
复制代码 两个方法效率一样的 |