回复 5# lxh623 - <#*,:
- @echo off
- cd /d "%~dp0"
- set "batchfile=%~f0"
- Powershell -ExecutionPolicy Bypass -C "Set-Location -LiteralPath ([Environment]::CurrentDirectory);. ([ScriptBlock]::Create([IO.File]::ReadAllText($env:batchfile,[Text.Encoding]::GetEncoding(0) )) )"
- pause
- exit /b
- #>
- # 复制文件
- # 1、J:\大藏经修改\modepub\epub解包后
- # 2、J:\大藏经修改\epub解包后
-
- $dir1 = "J:\大藏经修改\modepub\epub解包后"
- $dir2 = "J:\大藏经修改\epub解包后"
-
- # Robocopy.exe $dir1 $dir2 *.ttf *.ttc /S /MT
- Get-ChildItem -LiteralPath $dir1 | Where-Object { $_ -is [IO.DirectoryInfo] } | ForEach-Object {
- try {
- $_.Name
- $root1 = $_.FullName
- $root2 = [IO.Path]::Combine($dir2, $_.Name)
- if ([IO.Directory]::Exists($root2)) {
- $toc1 = Get-ChildItem -LiteralPath $root1 -Filter toc.ncx -Recurse | Where-Object { $_ -is [IO.FileInfo] } | Select-Object -First 1
- $toc2 = Get-ChildItem -LiteralPath $root2 -Filter toc.ncx -Recurse | Where-Object { $_ -is [IO.FileInfo] } | Select-Object -First 1
- if ($toc1 -and $toc2) {
- $toc1 | Copy-Item -Destination $toc2.FullName -Force
- }
- $opf2 = Get-ChildItem -LiteralPath $root2 -Filter content.opf -Recurse | Where-Object { $_ -is [IO.FileInfo] } | Select-Object -First 1
- if ($opf2) {
- $text = [IO.File]::ReadAllText($opf2.FullName)
- $text = $text.Replace('</manifest>', @'
- <item id="Cbeta.ttf" href="Fonts/Cbeta.ttf" media-type="application/x-font-ttf"/>
- </manifest>
- '@)
- [IO.File]::WriteAllText($opf2.FullName, $text)
- $fonts1 = Get-ChildItem -LiteralPath $root1 -Filter Fonts -Recurse | Where-Object { $_ -is [IO.DirectoryInfo] } | Select-Object -First 1
- if ($fonts1) {
- $fonts2 = [IO.Path]::Combine([IO.Path]::GetDirectoryName($opf2.FullName), 'Fonts')
- Robocopy.exe ($fonts1.FullName) $fonts2 * /S /MT
- }
- }
- }
- } finally {
-
- }
- trap {}
- }
复制代码
|