@echo off
call :txt2csv "1.txt" >1.csv
exit /b
:txt2csv <InputFile>
SetLocal EnableDelayedExpansion
for /f "usebackq tokens=*" %%i in ("%~1") do (
set str_full=%%i
for /f "tokens=1,2,3,4 delims=, " %%a in ("%%i") do (
echo %%~nxa,!str_full:*%%a=!
)
)
EndLocal
call :txt2csv "1.txt" >1.csv
exit /b
:txt2csv <InputFile>
SetLocal EnableDelayedExpansion
for /f "usebackq tokens=*" %%i in ("%~1") do (
set str_full=%%i
for /f "tokens=1,2,3,4 delims=, " %%a in ("%%i") do (
echo %%~nxa,!str_full:*%%a=!
)
)
EndLocal
goto :eof
参考:http://www.bathome.net/thread-26101-1-1.html