[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
bat存为ANSI/GB2312编码
  1. <# :
  2. cls&echo off&cd /d "%~dp0"&mode con lines=5000
  3. path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
  4. powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
  5. pause
  6. exit
  7. #>
  8. $oldfolder="J:\大藏经修改\modepub\epub解包后";
  9. $newfolder="J:\大藏经修改\epub解包后";
  10. $addline='    <item id="Cbeta.ttf" href="Fonts/Cbeta.ttf" media-type="application/x-font-ttf"/>';
  11. if(-not (test-path -literal $oldfolder)){write-host ('"'+$oldfolder+'" path error or not exist');exit;}
  12. if(-not (test-path -literal $newfolder)){write-host ('"'+$newfolder+'" path error or not exist');exit;}
  13. $enc=New-Object System.Text.UTF8Encoding $False;
  14. $folders=@(dir -literal $oldfolder|?{$_ -is [System.IO.DirectoryInfo]});
  15. for($i=0;$i -lt $folders.length;$i++){
  16.     write-host $folders[$i].Name;
  17.     $newpath=$newfolder+"\"+$folders[$i].Name;
  18.     $fd1=$folders[$i].FullName+"\OEBPS\Fonts";
  19.     $fd2=$newpath+"\OEBPS\Fonts";
  20.     if(test-path -literal $fd1){
  21.         remove-item -literal $fd2 -recurse -force -ErrorAction SilentlyContinue;
  22.         copy-item -literal $fd1 $fd2 -recurse -force -ErrorAction SilentlyContinue;
  23.     }
  24.     $f1=$folders[$i].FullName+"\OEBPS\toc.ncx";
  25.     $f2=$newpath+"\OEBPS\toc.ncx";
  26.     if(test-path -literal $f1){
  27.         copy-item -literal $f1 $f2 -force -ErrorAction SilentlyContinue;
  28.     }
  29.     $files=@(dir -literal $newpath -recurse|?{('content.opf' -eq $_.Name) -and ($_ -is [System.IO.FileInfo])});
  30.     for($j=0;$j -lt $files.length;$j++){
  31.         $text=[IO.File]::ReadAllText($files[$j].FullName, $enc);
  32.         $text=$text -replace '(?=<\/manifest>)',$addline;
  33.         [IO.File]::WriteAllText($files[$j].FullName, $text, $enc);
  34.     }
  35. }
复制代码
1

评分人数

提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表