找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 27223|回复: 2

[文本处理] 帮修改下替换文本字符串的bat代码

[复制链接]
发表于 2018-11-7 11:28:17 | 显示全部楼层 |阅读模式
  1. @echo off & setlocal EnableDelayedExpansion
  2. for /f "delims=" %%i in ('"dir /a/s/b/on *.html"') do (
  3. set file=%%~fi
  4. set file=!file:/=/!
  5. echo !file! >> sitemap.txt
  6. )
复制代码


执行后得到结果

D:\wwwroot\xxx.cn\403.html
D:\wwwroot\xxx.cn\404.html
D:\wwwroot\xxx.cn\index.html
D:\wwwroot\xxx.cn\play.html
D:\wwwroot\xxx.cn\sitemap.html
D:\wwwroot\xxx.cn\1213\js\mode\clike\index.html
D:\wwwroot\xxx.cn\1213\js\mode\clike\scala.html

如何把结果中
D:\wwwroot\ 替换成 www.
\替换成/
每行尾部有空格 去掉

怎么改一下代码 得到我需要的格式的结果

我想要的结果是
www.xxx.cn/403.html
www.xxx.cn/404.html
www.xxx.cn/index.html
www.xxx.cn/play.html
www.xxx.cn/sitemap.html
www.xxx.cn/1213/js/mode/clike/index.html
www.xxx.cn/1213/js/mode/clike/scala.html
发表于 2018-11-7 13:22:17 | 显示全部楼层
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. (for /f "delims=" %%i in ('dir /a/s/b/on *.html') do (
  4.     set "file=%%~fi"
  5.     set "file=!file:*:\wwwroot\=www.!"
  6.     set "file=!file:\=/!"
  7.     echo !file!
  8. ))> sitemap.txt
复制代码
发表于 2018-11-7 13:27:12 | 显示全部楼层
  1. //&cls&(dir /a/s/b/on *.html|cscript -nologo -e:jscript "%~f0")>>"导出.txt"&pause&exit
  2. WSH.echo(WSH.StdIn.ReadAll().replace(/\\/g, '/').match(/wwwroot.+/g).join('\r\n'));
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-18 20:49 , Processed in 0.017327 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表