批量删除报价&最后一次出现的字符串中的逗号

时间:2017-06-23 11:19:18

标签: batch-file

我有一个包含数据的文本文件

1,2,3,4,5,"100,6767.00"
1,2,3,4,5,"100,6767.00"
1,2,3,4,5,"100,6767.00"

我的预期输出

1,2,3,4,5,1006767.00
1,2,3,4,5,1006767.00
1,2,3,4,5,1006767.00

不幸的是,我有windows&试图制作批处理脚本

我知道如何在Linux中使用awk& SED

如何在Windows批处理文件中执行此操作?

2 个答案:

答案 0 :(得分:2)

编辑:

使用substitution结合tokens分隔的,数字:

@echo off

setlocal enabledelayedexpansion

(for /f "tokens=1-7 delims=," %%a in (Your_txt_file.txt) do (
  set "$line=%%a,%%b,%%c,%%d,%%e,%%f%%g"
  echo !$line:"=!
  )
  )>out.txt

答案 1 :(得分:1)

@echo off

(for /F tokens^=1^,2^ delims^=^" %%a in (input.txt) do (
   for /F "tokens=1,2 delims=," %%c in ("%%b") do echo %%a%%c%%d
)) > output.txt

输出示例:

1,2,3,4,5,1006767.00
1,2,3,4,5,1006767.00
1,2,3,4,5,1006767.00