[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  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. # 复制文件
  10. # 1、J:\大藏经修改\modepub\epub解包后
  11. # 2、J:\大藏经修改\epub解包后
  12. $dir1 = "J:\大藏经修改\modepub\epub解包后"
  13. $dir2 = "J:\大藏经修改\epub解包后"
  14. Robocopy.exe $dir1 $dir2 *.ttf *.ttc toc.ncx /S /MT
  15. Get-ChildItem -Path "$dir2\*" -Filter content.opf -Recurse | Where-Object { $_ -is [IO.FileInfo] } | ForEach-Object {
  16.   try {
  17.     $_ | Resolve-Path -Relative
  18.     $text = [IO.File]::ReadAllText($_.FullName)
  19.     $text = $text.Replace('</manifest>', @'
  20. <item id="Cbeta.ttf" href="Fonts/Cbeta.ttf" media-type="application/x-font-ttf"/>
  21. </manifest>
  22. '@)
  23.     [IO.File]::WriteAllText($_.FullName, $text)
  24.   } finally {
  25.    
  26.   }
  27.   trap {}
  28. }
复制代码
1

评分人数

微信:flashercs
QQ:49908356

TOP

回复 5# lxh623
  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. # 复制文件
  10. # 1、J:\大藏经修改\modepub\epub解包后
  11. # 2、J:\大藏经修改\epub解包后
  12. $dir1 = "J:\大藏经修改\modepub\epub解包后"
  13. $dir2 = "J:\大藏经修改\epub解包后"
  14. # Robocopy.exe $dir1 $dir2 *.ttf *.ttc /S /MT
  15. Get-ChildItem -LiteralPath $dir1 | Where-Object { $_ -is [IO.DirectoryInfo] } | ForEach-Object {
  16.   try {
  17.     $_.Name
  18.     $root1 = $_.FullName
  19.     $root2 = [IO.Path]::Combine($dir2, $_.Name)
  20.     if ([IO.Directory]::Exists($root2)) {
  21.       $toc1 = Get-ChildItem -LiteralPath $root1 -Filter toc.ncx -Recurse | Where-Object { $_ -is [IO.FileInfo] } | Select-Object -First 1
  22.       $toc2 = Get-ChildItem -LiteralPath $root2 -Filter toc.ncx -Recurse | Where-Object { $_ -is [IO.FileInfo] } | Select-Object -First 1
  23.       if ($toc1 -and $toc2) {
  24.         $toc1 | Copy-Item -Destination $toc2.FullName -Force
  25.       }
  26.       $opf2 = Get-ChildItem -LiteralPath $root2 -Filter content.opf -Recurse | Where-Object { $_ -is [IO.FileInfo] } | Select-Object -First 1
  27.       if ($opf2) {
  28.         $text = [IO.File]::ReadAllText($opf2.FullName)
  29.         $text = $text.Replace('</manifest>', @'
  30.   <item id="Cbeta.ttf" href="Fonts/Cbeta.ttf" media-type="application/x-font-ttf"/>
  31.   </manifest>
  32. '@)
  33.         [IO.File]::WriteAllText($opf2.FullName, $text)
  34.         $fonts1 = Get-ChildItem -LiteralPath $root1 -Filter Fonts -Recurse | Where-Object { $_ -is [IO.DirectoryInfo] } | Select-Object -First 1
  35.         if ($fonts1) {
  36.           $fonts2 = [IO.Path]::Combine([IO.Path]::GetDirectoryName($opf2.FullName), 'Fonts')
  37.           Robocopy.exe ($fonts1.FullName) $fonts2 * /S /MT
  38.         }
  39.       }
  40.     }
  41.   } finally {
  42.    
  43.   }
  44.   trap {}
  45. }
复制代码
1

评分人数

微信:flashercs
QQ:49908356

TOP

返回列表