powershell 提取 spotlight 图片

Yyqingmofeige 2019-11-06

powershell脚本来源于网络,有一些调整。

# 将复制出来的缓存图片保存在下面的文件夹  
$dir = Split-Path -Parent $MyInvocation.MyCommand.Definition
cd $dir
add-type -AssemblyName System.Drawing  
New-Item ".\Spotlight" -ItemType directory -Force;  
New-Item ".\Spotlight\CopyAssets" -ItemType directory -Force;  
New-Item ".\Spotlight\Horizontal" -ItemType directory -Force;  
New-Item ".\Spotlight\Vertical" -ItemType directory -Force;  
 

foreach($file in (Get-Item "$($env:LOCALAPPDATA)\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\*"))  
{  
    if ((Get-Item $file).length -le 200kb) { continue }  
    Copy-Item $file.FullName ".\Spotlight\CopyAssets\$($file.Name).png";  
}  
# 将横竖图片分别复制到对应的两个文件夹  
foreach($newfile in (Get-Item ".\Spotlight\CopyAssets\*"))  
{  
    $image = New-Object -comObject WIA.ImageFile;  
    $image.LoadFile($newfile.FullName);  
    if($image.Width.ToString() -ge "1920"){ Move-Item $newfile.FullName ".\Spotlight\Horizontal" -Force; }  
    elseif($image.Width.ToString() -le "1080"){ Move-Item $newfile.FullName ".\Spotlight\Vertical" -Force; }  
}

相关推荐

KINGJENSEN / 0评论 2012-04-16

includeGuYan / 0评论 2009-07-01