批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[文本处理] 批处理每行末尾追加字符出错

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for %%ii in (he.txt) do (echo%ii good >>ref.txt)
  4. pause
复制代码
想在每行后面添加good,运行出错。

此时不应有 %ii。

  1. @echo off
  2. (for /f "delims=" %%i in ('type "he.txt"') do (
  3.     echo %%i good
  4. ))>"ref.txt"
复制代码
【扫描二维码捐助论坛的朋友请留言注明论坛账号】http://bbs.bathome.net/thread-10403-1-1.html
【批处理在线视频分享】http://bbs.bathome.net/thread-31727-1-1.html
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html

TOP

回复 2# Batcher

运行结果是这个,如何修改代码?

i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good
i good

TOP

回复 2# Batcher

自己改好了,谢谢。

@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in (he.txt) do (
    echo %%i good >>ref.txt
  )
pause

TOP

本帖最后由 miqilaosu 于 2019-6-22 15:28 编辑

回复 1# netdzb


    你最开始的代码里有两处错误,找到了没?
  1. FOR %variable IN (set) DO command [command-parameters]
  2.   %variable  指定一个单一字母可替换的参数。
复制代码
第二个是echo和后边的语句连在一起了无法识别
要是说有第三处的话就是%i和%%i使用方法的区别你也算是老鸟了,估计是没注意

TOP

返回列表