本帖最后由 ygqiang 于 2024-10-21 19:32 编辑
[已解决]批处理,txt转htm,双击htm显示有乱码,如何解决?
主要功能需求:
txt文件内容经常手动修改。运行bat代码,就自动更新htm文件。
[已解决]
txt设置为ANSI格式- @echo off & setlocal enabledelayedexpansion
- echo 代码开始
-
- del /q 网址大全.htm
-
- for /f "delims=;" %%a in ('type 网址大全.txt') do (echo ^<a href=%%a^>%%a^<^/a^>^<br^> >>网址大全.htm)
复制代码 网址大全.txt文件内容如下:- 凡人124
- https://dyxs31.com/paly-86355-10-102/
-
- 完美184
- https://waipian28.com/play/476-7-173/
-
- 仙逆59
- https://www.yingshikong1.com/play/121193-1-50.html
-
- 诛仙58
- https://dyxs38.com/paly-224772-9-52/
复制代码 更新下最终代码:(3种方法)- @echo off & setlocal enabledelayedexpansion
- if "%1" == "h" goto begin
- mshta vbscript:createobject("wscript.shell").run("%~fs0 h",0)(window.close)&&exit
- :begin
- rem 下边开始写批处代码了(适合全自动场合)
-
- set wjm=网址-方法1.htm
- set wjm1=方法1网址.txt
-
- echo ^<br^>>%wjm%
- echo ^<br^>>>%wjm%
- echo ^<br^>>>%wjm%
- echo ^<br^>>>%wjm%
-
- (set "v=" &echo,^<style^>a{font-size:60px;}^</style^>
- for /f "eol= delims=" %%s in (%wjm1%) do if not defined v (set "v=%%s</a><br>") else (
- echo,^<a href=%%s^>!v!
- set "v="
- ))>>%wjm%
-
- start /max "" "%wjm%" & cls & ping 0 -n 3 >nul 2>nul & del /q "%wjm%.htm11"
-
- exit
复制代码
- @echo off & setlocal enabledelayedexpansion
- if "%1" == "h" goto begin
- mshta vbscript:createobject("wscript.shell").run("%~fs0 h",0)(window.close)&&exit
- :begin
- rem 下边开始写批处代码了(适合全自动场合)
-
- set wjm=网址-方法2.htm
- set wjm1=方法2网址.txt
-
-
- echo ^<font size="9"^>^<br^>>%wjm%
-
- 1pause >nul 2>nul
-
- set "v=" & (for /f "eol= delims=" %%s in (%wjm1%) do if not defined v (set "v=%%s</a><br>") else (
- echo,^<a href=%%s^>!v!
- set "v="
- ))>>%wjm%
-
- 1pause >nul 2>nul
-
- echo ^</font^>>>%wjm%
-
- start /max "" "%wjm%" & cls & ping 0 -n 3 >nul 2>nul & del /q "%wjm%.htm11"
-
- exit
复制代码
- @echo off & setlocal enabledelayedexpansion
- if "%1" == "h" goto begin
- mshta vbscript:createobject("wscript.shell").run("%~fs0 h",0)(window.close)&&exit
- :begin
- rem 下边开始写批处代码了(适合全自动场合)
- set wjm=网址-方法3
- for /f "delims=:" %%i in ('findstr /n "^:del-dir$" "%~f0"') do (
- more +%%i "%~f0" > %wjm%.txt
- )
- echo ^<font size="9"^>^<br^>>%wjm%.htm
- set "v=" & (for /f "eol= delims=" %%s in (%wjm%.txt) do if not defined v (set "v=%%s</a><br>") else (
- echo,^<a href=%%s^>!v!
- set "v="
- ))>>%wjm%.htm
- echo ^</font^>>>%wjm%.htm
- start /max "" "%wjm%.htm" & cls & ping 0 -n 3 >nul 2>nul & del /q "%wjm%.htm11" & del /q "%wjm%.txt"
- exit
- ———————————————————————
- :del-dir
- 凡人124
- https://dyxs31.com/paly-86355-10-102/
- 完美185
- https://waipian28.com/play/476-7-173/
- 仙逆59
- https://www.yingshikong1.com/play/121193-1-50.html
- 诛仙52
- https://dyxs38.com/paly-224772-9-52/
复制代码
|