Board logo

标题: [文本处理] 批处理如何在txt文本每行指定位置添加/插入指定字符? [打印本页]

作者: xen    时间: 2013-1-3 13:56     标题: 批处理如何在txt文本每行指定位置添加/插入指定字符?

本帖最后由 pcl_test 于 2016-9-3 14:34 编辑

现在有
  1. http://baidu.com/480x320/0100000.jpg
  2. http://baidu.com/480x320/0100001.jpg
  3. http://baidu.com/480x320/0100002.jpg
  4. http://baidu.com/480x320/0100003.jpg
  5. ....(N行)
复制代码
怎么样通过批处理成
  1. http://baidu.com/480x320/01_000_00.jpg
  2. http://baidu.com/480x320/01_000_01.jpg
  3. http://baidu.com/480x320/01_00_002.jpg
  4. http://baidu.com/480x320/01_000_03.jpg
  5. ....(N行)
复制代码
或者直接通过批处理生成
万分感谢
作者: BAT-VBS    时间: 2013-1-3 16:46

第三行为什么是01_00_002.jpg?而不是01_000_02.jpg?
作者: pcl_test    时间: 2016-9-3 14:41

  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "delims=" %%a in ('more +6 "%~f0"') do (
  3.     set "str=%%a"
  4.     echo;!str:~,-9!_!str:~-9,3!_!str:~-6!
  5. )
  6. pause&exit
  7. http://baidu.com/480x320/0100000.jpg
  8. http://baidu.com/480x320/0100001.jpg
  9. http://baidu.com/480x320/0100002.jpg
  10. http://baidu.com/480x320/0100003.jpg
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2