[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 zaqmlp 于 2019-8-29 20:57 编辑
  1. <div class="calibre3">本书由“<a href="http://epubw.com" class="calibre1">ePUBw.COM</a>”整理,<a href="http://epubw.com" class="calibre1">ePUBw.COM</a> 提供最新最全的优质电子书下载!!!</div>
  2. ---------------------------
  3. <div class="calibre2">本书由“<a href="http://epubw.com" class="calibre1">ePUBw.COM</a>”整理,<a href="http://epubw.com" class="calibre1">ePUBw.COM</a> 提供最新最全的优质电子书下载!!!</div>
  4. ---------------------------
  5. <div class="calibre5">本书由“<a href="http://epubw.com" class="calibre1">ePUBw.COM</a>”整理,<a href="http://epubw.com" class="calibre1">ePUBw.COM</a> 提供最新最全的优质电子书下载!!!</div>
复制代码
新建一个utf-8编码的叫“删除.txt”的文本,将要删除的内容按上面格式填入;将txt、bat跟epub放一起运行,需安装winrar,并在代码中指定好安装路径
  1. <# :
  2. @echo off
  3. set info=互助互利,支付宝扫码头像,感谢赞助
  4. rem 有问题,可加QQ956535081及时沟通
  5. title %info%
  6. set "rootpath=%~dp0"
  7. if "%rootpath:~-1%" equ "\" (set "rootpath=%rootpath:~,-1%")
  8. cd /d "%rootpath%"
  9. set "zipexe=C:\Program Files\7-Zip\7za.exe"
  10. if not exist "%zipexe%" (echo;"%zipexe%" not found&goto end)
  11. for /f "delims=" %%a in ('dir /a-d/b *.epub') do (
  12.     echo;解压"%%a"
  13.     md ".\%%~na\" 2>nul
  14.     "%zipexe%" x -tzip ".\%%a" -o".\%%~na\"
  15. )
  16. powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%rootpath%'"
  17. set "fd=#结果"
  18. if exist ".\%fd%\" rd /s /q ".\%fd%\"
  19. for /f "delims=" %%a in ('dir /ad/b') do (
  20.     if not exist ".\%fd%\" md ".\%fd%\"
  21.     echo;打包"%%~nxa"
  22.     "%zipexe%" a -tzip ".\%fd%\%%~nxa.zip" ".\%%~nxa\*"
  23.     ren ".\%fd%\%%~nxa.zip" "%%~nxa.epub"
  24.     rem rd /s /q ".\%%~nxa\"
  25.     echo;---------------------
  26. )
  27. :end
  28. echo;%info%
  29. pause
  30. exit
  31. #>
  32. $deltxt='删除.txt';
  33. $text=[IO.File]::ReadAllText($deltxt, [Text.Encoding]::UTF8);
  34. $tmp=$text -split '\r?\n-{8,}\r\n';
  35. $Utf8NoBom=New-Object System.Text.UTF8Encoding $False;
  36. $folders=@(dir -liter $args[0]|?{$_ -is [System.IO.DirectoryInfo]});
  37. for($i=0;$i -lt $folders.count;$i++){
  38.     $files=@(dir -liter $folders[$i].FullName -r|?{(@('.xhtml','.html') -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  39.     for($j=0;$j -lt $files.count;$j++){
  40.         write-host $files[$j].FullName.replace($args[0],'');
  41.         $text=[IO.File]::ReadAllText($files[$j].FullName, $Utf8NoBom);
  42.         for($k=0;$k -lt $tmp.count;$k++){
  43.             $text=$text.replace($tmp[$k],'');
  44.         };
  45.         [IO.File]::WriteAllText($files[$j].FullName, $text, $Utf8NoBom);
  46.     };
  47. };
复制代码
1

评分人数

    • lxh623: 谢谢!请查收!技术 + 1
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

本帖最后由 zaqmlp 于 2019-8-29 21:01 编辑

回复 9# lxh623

删除.txt里的内容是按里面xhtml的原文内容添加,原文没空格,所以就没空格
已修改,改用7z解包打包
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表