bat存为ANSI/GB2312编码- <# :
- cls&echo off&cd /d "%~dp0"&mode con lines=5000
- path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
- pause
- exit
- #>
- $oldfolder="J:\大藏经修改\modepub\epub解包后";
- $newfolder="J:\大藏经修改\epub解包后";
- $addline=' <item id="Cbeta.ttf" href="Fonts/Cbeta.ttf" media-type="application/x-font-ttf"/>';
- if(-not (test-path -literal $oldfolder)){write-host ('"'+$oldfolder+'" path error or not exist');exit;}
- if(-not (test-path -literal $newfolder)){write-host ('"'+$newfolder+'" path error or not exist');exit;}
- $enc=New-Object System.Text.UTF8Encoding $False;
- $folders=@(dir -literal $oldfolder|?{$_ -is [System.IO.DirectoryInfo]});
- for($i=0;$i -lt $folders.length;$i++){
- write-host $folders[$i].Name;
- $newpath=$newfolder+"\"+$folders[$i].Name;
- $fd1=$folders[$i].FullName+"\OEBPS\Fonts";
- $fd2=$newpath+"\OEBPS\Fonts";
- if(test-path -literal $fd1){
- remove-item -literal $fd2 -recurse -force -ErrorAction SilentlyContinue;
- copy-item -literal $fd1 $fd2 -recurse -force -ErrorAction SilentlyContinue;
- }
- $f1=$folders[$i].FullName+"\OEBPS\toc.ncx";
- $f2=$newpath+"\OEBPS\toc.ncx";
- if(test-path -literal $f1){
- copy-item -literal $f1 $f2 -force -ErrorAction SilentlyContinue;
- }
- $files=@(dir -literal $newpath -recurse|?{('content.opf' -eq $_.Name) -and ($_ -is [System.IO.FileInfo])});
- for($j=0;$j -lt $files.length;$j++){
- $text=[IO.File]::ReadAllText($files[$j].FullName, $enc);
- $text=$text -replace '(?=<\/manifest>)',$addline;
- [IO.File]::WriteAllText($files[$j].FullName, $text, $enc);
- }
- }
复制代码
|