I want to append a fixed string after href="/ in HTML files, for example: change href="/abc.html"
to href="/aaa/abc.html"
When I tried using set, I found that
1. The = " in the original string all need to be escaped, otherwise it can't be replaced correctly;
2. All the Chinese in the new file turns into garbled text
Below is the code I wrote. Please give me some guidance, experts, I would be very grateful! :)
---------------------------
@echo off
for /f "delims=" %%i in ('dir /a /b /s *.html') do (
for /f "delims=" %%a in (%%i) do (
set var=%%a
set "var=!var:%%href="/=href=”/aaa/%%!"
echo !var!>>%%i.txt
)
del %%i
ren "%%i.txt" %%i
)
---------------------
[ Last edited by samuel on 2008-1-1 at 07:46 PM ]
to href="/aaa/abc.html"
When I tried using set, I found that
1. The = " in the original string all need to be escaped, otherwise it can't be replaced correctly;
2. All the Chinese in the new file turns into garbled text
Below is the code I wrote. Please give me some guidance, experts, I would be very grateful! :)
---------------------------
@echo off
for /f "delims=" %%i in ('dir /a /b /s *.html') do (
for /f "delims=" %%a in (%%i) do (
set var=%%a
set "var=!var:%%href="/=href=”/aaa/%%!"
echo !var!>>%%i.txt
)
del %%i
ren "%%i.txt" %%i
)
---------------------
[ Last edited by samuel on 2008-1-1 at 07:46 PM ]
