本帖最后由 went 于 2021-10-4 10:05 编辑
保存bat文件- @cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" &pause&exit
- Get-ChildItem 'epub解包\*' | Where-Object {[System.IO.Directory]::Exists($_.FullName)} | foreach {
- $_.FullName
- $f1 = $_.FullName + '\text'
- $f2 = $_.FullName + '\images'
- if([System.IO.Directory]::Exists($f1) -and [System.IO.Directory]::Exists($f2)){
- $images1 = &{
- Get-ChildItem ($f1 + '\*.html') | foreach {
- Get-Content $_.FullName | foreach {
- if($_ -match 'src="../images/(.*?.jpeg)'){
- $Matches[1]
- }
- }
- }
- } | Select-Object -Unique
- Get-ChildItem ($f2 + '\*.jpeg') | Where-Object { $images1 -notcontains $_.Name } | foreach {
- '删除: ' + $_.FullName
- Remove-Item $_
- }
- }
- '---------------------------'
- }
复制代码
|