本帖最后由 wujunkai 于 2020-6-20 13:47 编辑
- @echo off & setlocal enabledelayedexpansion
-
- :main
- set count=0
- call:fopen one.txt text
- set /A lines=fopen_len-1
- for /L %%i in (0,1,%lines%) do (
- call:len text[%%i]
- call:deal %%i
- )
- echo %count%
- pause
- goto:eof
-
- :deal
- set word=!text[%~1]!
- set /A len-=2
- for /L %%i in (0,1,%len%) do if /I "!word:~%%i,3!"=="mp3" set /A count+=1
- goto:eof
-
- :len
- set len_cpy=!%~1!
- set len=0
- for %%i in (1024,512,256,128,64,32,16,8,4,2,1) do if not "!len_cpy:~%%i,1!"=="" (
- set /A len+=%%i
- set len_cpy=!len_cpy:~%%i!
- )
- goto:eof
-
- :fopen
- set fopen_file=%~1
- if "%~2"=="" ( set "fopen_vale=%~n1" ) else ( set "fopen_vale=%~2" )
- set fopen_len=0
- for /F "tokens=1* delims=:" %%i in ('findstr /n .* %fopen_file%') do (
- set %fopen_vale%[!fopen_len!]=%%j
- set /A fopen_len+=1
- )
- goto:eof
复制代码
|