这是输入文件: -
Hello,1-23456 How are you,2-34567 . . .
我想要输出: -
1-23456,Hello 2-34567,How are you . . .
请帮我为此创建一个批处理文件。
我试过这个
@echo off &setlocal set "textfile=inputchq.csv" set "newfile=output.txt" (for /f "tokens=1,2 delims=," %%i in (%textfile%) do set srno=%%a&set comments=%%b ( set "line=%%i" setlocal enabledelayedexpansion set "line=%comments%,%srno%" echo(!line! endlocal ))>>"%newfile%"
但我没有得到所需的输出
答案 0 :(得分:0)
@echo off &setlocal
set "textfile=inputchq.csv"
set "newfile=output.txt"
(for /f "tokens=1,2 delims=," %%a in (%textfile%) do (
echo %%b,%%a"
))>>"%newfile%"
编辑以符合评论中的其他要求:
你需要延迟扩张并逃避特殊角色" |"
@echo off
setlocal enabledelayedexpansion
set "textfile=inputchq.csv"
set "newfile=output.txt"
(for /f "tokens=1,2 delims=," %%a in (%textfile%) do (
set "line=%%b,%%a"
echo !line:^|=.!
))>>%newfile%