[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <# :
  2. cls&echo off&cd /d "%~dp0"&mode con lines=5000&rem bat存为ANSI/GB2312编码
  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. $folder1="D:\大藏经修改\梵文";
  9. $folder2="D:\大藏经修改\epub解包后\F1071 釋教最上乘秘密藏陀羅尼集\OEBPS\juans";
  10. if(-not (test-path -literal $folder1)){write-host ('"'+$folder1+'" path error or not exist');exit;}
  11. if(-not (test-path -literal $folder2)){write-host ('"'+$folder2+'" path error or not exist');exit;}
  12. $enc=New-Object System.Text.UTF8Encoding $False;
  13. $files=@(dir -literal $folder1|?{('.xhtml' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  14. if($files.length -ge 1){
  15.     for($i=0;$i -lt $files.length;$i++){
  16.         write-host $files[$i].FullName -ForegroundColor yellow;
  17.         $arr=New-Object -TypeName System.Collections.ArrayList;
  18.         $text1=[IO.File]::ReadAllText($files[$i].FullName, $enc);
  19.         $m1=[regex]::matches($text1, 'class="text_3">([^<]+)');
  20.         $m2=[regex]::match($files[$i].Name, '(?i)_([0-9]+\.xhtml)$');
  21.         if($m2.Success){
  22.             $juansfile=$folder2.trimend('\')+'\'+$m2.groups[1].value;
  23.             if(test-path -literal $juansfile){
  24.                 write-host $juansfile -ForegroundColor yellow;
  25.                 $global:n=0
  26.                 $text2=[IO.File]::ReadAllText($juansfile, $enc);
  27.                 $text2=[regex]::replace($text2, 'class="text_3">([^<]+)', {
  28.                     param($m3);
  29.                     $str=$m3.groups[0].value;
  30.                     if($global:n -lt $m1.count){
  31.                         if($m3.groups[1].value.Contains($m1[$global:n].groups[1].value)){
  32.                             $str=$m1[$global:n].groups[0].value;
  33.                             [void]$arr.add('');
  34.                             write-host ($m1[$global:n].groups[1].value+' --> '+$m3.groups[1].value);
  35.                         }else{
  36.                            [void]$arr.add($m1[$global:n].groups[1].value);
  37.                         }
  38.                     }
  39.                     $global:n++;
  40.                     return $str;
  41.                 });
  42.                 [IO.File]::WriteAllText($juansfile, $text2, $enc);
  43.             }else{write-host ('"'+$juansfile+'" not exist');}
  44.         }
  45.         for($j=$global:n;$j -lt $m1.count;$j++){
  46.             [void]$arr.add($m1[$j].groups[1].value);
  47.         }
  48.         $outfile=$folder1.trimend('\')+'\'+$files[$i].BaseName+'.txt';
  49.         [IO.File]::WriteAllLines($outfile, $arr, $enc);
  50.         write-host '';
  51.     }
  52. }else{write-host ('no xhtmlfile in "'+$folder1+'"');}
复制代码
1

评分人数

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

TOP

回复 6# lxh623


不清楚你的实际目录结构是怎样,你原来网盘上传的跟现在说明的完全不符,你要么就按我写的目录结构,要么就重新整理打包上传
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

本帖最后由 zaqmlp 于 2023-4-19 14:31 编辑

回复 8# lxh623


    怎么知道“梵文”文件夹里哪些xhtml是跟“F1071 釋教最上乘秘密藏陀羅尼集\OEBPS\juans”里的xhtml对应呀?!需求要说清楚,而不是让人来猜
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 11# lxh623

还是没说清楚,比如T18n0894_001.xhtml、T18n0894a_001.xhtml、T18n0894b_001.xhtml,都是对应同一个“T0894 xxxxx”文件夹下OEBPS\juans里的001.xhtml吗?!
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表