powershell 提取 spotlight 图片

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

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

foreach($file in (Get-Item "$($env:LOCALAPPDATA)PackagesMicrosoft.Windows.ContentDeliveryManager_cw5n1h2txyewyLocalStateAssets*"))  
{  
    if ((Get-Item $file).length -le 200kb) { continue }  
    Copy-Item $file.FullName ".SpotlightCopyAssets$($file.Name).png";  
}  
# 将横竖图片分别复制到对应的两个文件夹  
foreach($newfile in (Get-Item ".SpotlightCopyAssets*"))  
{  
    $image = New-Object -comObject WIA.ImageFile;  
    $image.LoadFile($newfile.FullName);  
    if($image.Width.ToString() -ge "1920"){ Move-Item $newfile.FullName ".SpotlightHorizontal" -Force; }  
    elseif($image.Width.ToString() -le "1080"){ Move-Item $newfile.FullName ".SpotlightVertical" -Force; }  
}  
 
原文地址:https://www.cnblogs.com/wswind/p/11808939.html