- @echo off & setlocal enabledelayedexpansion
- if exist new.csv del new.csv
- set data=D37,E39,D38
- for %%a in (%data%) do (
- echo Process %%a
- set /a d+=1
- for %%b in (A B C D E F G H I J K L M) do (
- set str=%%a
- set /a n+=1
- if "!str:~,1!"=="%%b" call :take !n! !str:~1,3! !d!
- )
- set n=
- )
- (for /f "delims=: tokens=2" %%a in ('findstr /n . new.csv^|findstr "1: 4: 7:"') do set /p=%%a,<nul)>$$.csv
- echo.>>$$.csv
- (for /f "delims=: tokens=2" %%a in ('findstr /n . new.csv^|findstr "2: 5: 8:"') do set /p=%%a,<nul)>>$$.csv
- echo.>>$$.csv
- (for /f "delims=: tokens=2" %%a in ('findstr /n . new.csv^|findstr "3: 6: 9:"') do set /p=%%a,<nul)>>$$.csv
- move /y $$.csv new.csv >nul
- start "" new.csv
- exit
- :take
- set /a h=%2-1
- for /f "delims=" %%a in ('dir /b *.csv') do (
- for /f "skip=%h% delims=" %%b in ('type "%%a"') do (
- set str=%%b
- set str=!str:,=,$!
- for /f "delims=, tokens=%1" %%c in ("!str!") do (
- if "!a!"=="" (set str=%%c&>>new.csv echo !str:$=!)
- set a=1
- )
- )
- set a=
- )
- goto :eof
复制代码 这代码我也是醉了,效率不高,不然得下功夫 |