保存为 重命名epub.bat,编码是ANSI. | | | | | | | | | | | | | | | | | | | | | $a = @' | | T17n0784--四十二章经--後汉 迦叶摩腾共法兰译 | | T39n1794--注四十二章经--宋 真宗皇帝注 | | X37n0669--四十二章经注--宋 守遂注 明 了童补注 | | X37n0670--四十二章经解--明 智旭著 | | X37n0671--四十二章经疏钞--清 续法述 | | '@ | | | | $arr = $a.Trim() -split '[\r\n]+' | | Add-Type -AssemblyName Microsoft.VisualBasic | | | | | | Get-ChildItem -Path . | Where-Object { $_ -is [IO.FileInfo] -and $_.FullName -ne $env:batchfile -and $_.Name -ne 'a.txt' } | Rename-Item -NewName { | | [Microsoft.VisualBasic.Strings]::StrConv($_.Name, [Microsoft.VisualBasic.VbStrConv]::SimplifiedChinese, 0) | | } -Verbose -ErrorAction SilentlyContinue | | | | | | $di = [IO.Directory]::CreateDirectory('新建文件夹') | | Get-ChildItem -Path . | Where-Object { $_ -is [IO.FileInfo] -and $_.FullName -ne $env:batchfile -and $_.Name -ne 'a.txt' -and $_.Name -match '\b\d{3}\b' } | Move-Item -Destination ($di.FullName) -Verbose | | | | | | Get-ChildItem -Path . | Where-Object { $_ -is [IO.FileInfo] -and $_.FullName -ne $env:batchfile -and $_.Name -ne 'a.txt' } | Rename-Item -NewName { | | $k = ($_.BaseName -split '\s+')[0] | | $newBaseName = $arr -match "--$([regex]::Escape(${k}))--" | Select-Object -First 1 | | if ($newBaseName) { | | $newBaseName + $_.Extension | | } else { | | $_.Name | | } | | } -Verbose -ErrorAction SilentlyContinueCOPY |
|