字符替换

来源:百度知道 编辑:UC知道 时间:2024/06/14 16:06:30
地址:/html/1/1/5.htm

地址:/html/1/2/5.htm

地址:/html/1/3/5.htm

地址:/html/1/4/5.htm

地址:/html/1/5/5.htm

地址:/html/1/6/5.htm

有没有什么办法把
/html/movie/1/这里批量替换掉/5.htm
孤星 你给的只能替换掉5.htm
自己瞎修改了下,达到目的。。
孤星,谢谢你了
@echo off
for /f "delims=/ tokens=1-4*" %%3 in (1.txt) do (
if "%%2"=="" (
echo %%3 >>temp.txt
echo\ >>temp.txt
) else (
echo /%%3/%%4 >>temp.txt
)
)
start temp.txt

你这是放在一个txt文件中的数据?
替换掉/html/1/35818/5.htm中的/35818??替换后:/html/1/5.htm?
为了以防万一把数据搞乱了,我写个命令把它替换重新导入到一个新的文件temp.txt中.

@echo off
for /f "delims=/ tokens=1-4*" %%a in (要处理文件.txt) do (
if "%%b"=="" (
echo %%a >>temp.txt
echo\ >>temp.txt
) else (
echo %%a/%%b/%%c/%%e >>temp.txt
)
)
start temp.txt

运行后你再比较下两个文件,看是否达到目的了..