- <# :
- cls&echo off&cd /d "%~dp0"&mode con lines=5000
- path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
- set "current=%cd%"
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
- pause
- exit
- #>
- $insertstr=' <item id="Cbeta.ttf" href="Fonts/Cbeta.ttf" media-type="application/x-font-ttf"/>';
- $current=($env:current).trimend('\');
- $enc=New-Object System.Text.UTF8Encoding $False;
- $folders=@(dir -literal $current -recurse|?{$_ -is [System.IO.DirectoryInfo]});
- for($i=0;$i -lt $folders.length;$i++){
- if($folders[$i].Name -eq 'OEBPS'){
- $ttffile=$folders[$i].FullName+'\Fonts\Cbeta.ttf';
- $opffile=$folders[$i].FullName+'\content.opf';
- if((test-path -literal $ttffile) -and (test-path -literal $opffile)){
- write-host $ttffile;
- write-host $opffile;
- $text=[IO.File]::ReadAllText($opffile, $enc);
- $text=[regex]::replace($text, '([^\r\n]+([\r\n]+))([\t ]*?</manifest>)', {
- param($m);
- if($m.groups[0].value.Contains($insertstr)){
- return $m.groups[0].value;
- }else{
- return $m.groups[1].value+$insertstr+$m.groups[2].value+$m.groups[3].value;
- }
- });
- [IO.File]::WriteAllText($opffile, $text, $enc);
- write-host '';
- }
- }
- }
复制代码
|