本帖最后由 zaqmlp 于 2018-2-13 23:15 编辑
- @echo off
- rem 测试前先备份zip文件
- rem bat与zip放一起运行
- rem 指定WinRAR安装路径
- set "rarpath=C:\Program Files\WinRAR\WinRAR.exe"
-
- set "tmpfd=$tmp"
- if not exist "%rarpath%" echo;WinRAR程序不存在或路径错误&pause&exit
- md "%tmpfd%" 2>nul
-
- echo;解压
- for /f "delims=" %%a in ('dir /a-d/b *.zip') do (
- echo;"%%a"
- "%rarpath%" x -ibck "%%a" "%tmpfd%\%%~na\"
- )
-
- echo;替换txt内容
- powershell "dir '%~dp0%tmpfd%\' *.txt -r|%%{$txt=(gc $_.FullName) -join \"`r`n\";$txt.replace('xx小说网(xx.com)','yy小说(yy.com)').replace('xx小说网提供下载','yy小说网提供下载')|out-file $_.FullName -enc Default}"
-
- echo;重新打包并覆盖原zip
- for /f "delims=" %%a in ('dir /ad /b "%tmpfd%\"') do (
- echo;"%tmpfd%\%%a"
- "%rarpath%" a -ep1 -r -y -ibck "%~dp0%%a.zip" "%tmpfd%\%%a\"
- )
-
- rd /s /q "%tmpfd%\"
- pause
复制代码
|