Board logo

标题: [文本处理] [已解决]批处理怎样写入完整路劲到TXT中? [打印本页]

作者: heroxianf    时间: 2011-5-4 08:03     标题: [已解决]批处理怎样写入完整路劲到TXT中?

本帖最后由 heroxianf 于 2011-5-4 12:58 编辑

任意一个文件夹下 比如 D:/ICO 文件夹里有 1.ico、2.ico

使用批处理写入test.txt里的内容是
go "d:/ico/1.ico"
go "d:/ico/2.ico"



请坛友帮帮忙!
作者: heroxianf    时间: 2011-5-4 08:13

  1. @echo off
  2. DIR /B >>test.txt
  3. for /f "tokens=*" %%a in (.\test.txt) do (
  4.   for /r %CD% %%j in (%%a) do (
  5.     if exist %%j (
  6.       echo %%j>>text_new.txt
  7.     )
  8.   )
  9. )
复制代码
我用它能实现文件完整路径写入TXT  但是如何加一个 “go”
作者: heroxianf    时间: 2011-5-4 08:27

  1. @echo off
  2. REM 清理TXT
  3. del /q test.txt
  4. del /q text_new.txt
  5. DIR /B >>test.txt
  6. for /f "tokens=*" %%a in (.\test.txt) do (
  7.   for /r %CD% %%j in (%%a) do (
  8.     if exist %%j (
  9.       echo "%%j">>text_new.txt
  10.     )
  11.   )
  12. )
复制代码
这样就能给每个路径加上双引号了!   请坛友帮忙  加“go”
作者: hucuibai    时间: 2011-5-4 10:14

  1. @echo off
  2. for /r D:/ICO %%i in (*..ico) do (
  3.          >test.txt (echo go "%%i")
  4.           )
复制代码

作者: heroxianf    时间: 2011-5-4 11:23

4# hucuibai

谢谢  试了下能实现~




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