- @echo off
- cd /d "%~dp0"
- set "srcfile=1.txt"
- set "dstfile=2.txt"
- set "tmpfile1=%temp%\~a.tmp"
- set "tmpfile2=%temp%\~b.tmp"
- cd .>"%tmpfile1%"
- cd .>"%tmpfile2%"
- setlocal EnableDelayedExpansion
- set tmpflag=0
- set line=0
- for /f "usebackq delims=" %%A in ("%srcfile%") do (
- set /a line+=1
- set str!line!=%%A
- if !line! equ 3 (
- if !tmpflag! equ 0 (
- >>%tmpfile1% (echo,!str3!&echo,!str1!&echo,!str2!)
- set tmpflag=1
- ) else (
- >>%tmpfile2% (echo,!str2!&echo,!str1!&echo,!str3!)
- set tmpflag=0
- )
- set line=0
- )
- )
- endlocal
- copy /y /b "%tmpfile1%"+"%tmpfile2%" "%dstfile%"
- del "%tmpfile1%"
- del "%tmpfile2%"
- pause
- exit /b
复制代码
|