[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 8# lxh623

保存为 合并epub.bat,编码ANSI,此脚本放到解包后的文件夹内.
  1. <#*,:
  2. @echo off
  3. cd /d "%~dp0"
  4. set "batchfile=%~f0"
  5. Powershell -ExecutionPolicy Bypass -C "Set-Location -LiteralPath ([Environment]::CurrentDirectory);. ([ScriptBlock]::Create([IO.File]::ReadAllText($env:batchfile,[Text.Encoding]::GetEncoding(0) )) )"
  6. pause
  7. exit /b
  8. #>
  9. # 合并epub xhtml css,此脚本放到 解包后 文件夹内
  10. Get-ChildItem -Path . | Where-Object { $_ -is [IO.DirectoryInfo] -and $_.FullName -ne $env:batchfile } | Group-Object -Property @{
  11.   Expression = { $_.Name -replace '第\s+\d+\s+卷' }
  12. } | ForEach-Object {
  13.   $di1 = $_.Group | Where-Object { $_.Name -match '第\s+(\d+)\s+卷' -and $Matches[1] -eq '1' } | Select-Object -First 1
  14.   if ($null -eq $di1) { return }
  15.   if($_.Group.Count -le 1){return}
  16.   $opf = [IO.Path]::Combine($di1.FullName, 'OEBPS\content.opf')
  17.   $xml = [IO.File]::ReadAllText($opf)
  18.   if (-not $?) { return }
  19.   # 把第一个里面的xhtml后面加001,或者直接改001 。把后面文件夹的,依次复制到第一个那里。并且命名002,003等等。
  20.   # Get-ChildItem -LiteralPath ([IO.Path]::Combine($di1.FullName,'OEBPS\pages')) -Filter *.xhtml|Rename-Item -NewName '001.xhtml'
  21.   $di1.Name | Out-Host
  22.   $_.Group | Where-Object { $_ -ne $di1 } | ForEach-Object {
  23.     # $null = $_.Name -match '第\s+(\d+)\s+卷'
  24.     # $strctr = $Matches[1]
  25.     Get-ChildItem -LiteralPath ([IO.Path]::Combine($_.FullName, 'OEBPS\pages')) -Filter *.xhtml | ForEach-Object {
  26.       $fi2 = $_ | Copy-Item -Destination ([IO.Path]::Combine($di1.FullName, "OEBPS\pages")) -PassThru
  27.       if ($fi2) {
  28.         $xml = $xml.Replace("</manifest>", @"
  29. <item id="$($fi2.Name)" href="Text/$($fi2.Name)" media-type="application/xhtml+xml"/></manifest>
  30. "@).Replace("</spine>", @"
  31. <itemref idref="$($fi2.Name)"/></spine>
  32. "@)
  33.       }
  34.     }
  35.     Get-ChildItem -LiteralPath ([IO.Path]::Combine($_.FullName, 'OEBPS\style')) -Filter *.css | ForEach-Object {
  36.       $fi2 = $_ | Copy-Item -Destination ([IO.Path]::Combine($di1.FullName, "OEBPS\style")) -PassThru
  37.       if ($fi2) {
  38.         $xml = $xml.Replace("</manifest>", @"
  39. <item id="$($fi2.Name)" href="Styles/$($fi2.Name)" media-type="text/css"/></manifest>
  40. "@)
  41.       }
  42.     }
  43.   }
  44.   [IO.File]::WriteAllText($opf, $xml)
  45. }
复制代码
1

评分人数

微信:flashercs
QQ:49908356

TOP

回复 10# lxh623


通过百度网盘分享的文件:cbeta白话文制作
链接:https://pan.baidu.com/s/10YwAhgGyHO57CwpARcb1gA
提取码:i5dx
微信:flashercs
QQ:49908356

TOP

返回列表