如果年份、期号、页码的位数都固定的话,比较好办,不然还要反复切割:- @echo off
- set hh=^
-
-
- (for /f "delims=" %%a in ('sort b.txt') do (
- set str=%%a
- for /f "delims=0123456789" %%b in ("%%a") do (
- set 报纸=%%b
- setlocal enabledelayedexpansion
- set tmp=!str:*%%b=!
- set 年份=!tmp:~,5!
- set 期号=!tmp:~5,4!
- set 页码=!tmp:~9,3!
- set 案件=!tmp:*_=!
- for %%c in (报纸 年份 期号) do (
- if !last%%c! neq !%%c! (
- echo !%%c!
- set last%%c=!%%c!
- )
- )
- echo !案件!_!页码!
- for /f "delims=" %%b in ("last报纸=!last报纸!!hh!last年份=!last年份!!hh!last期号=!last期号!") do (
- endlocal
- set "%%b"
- )
- )
- ))>c.txt
- pause
复制代码
|