Loading

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 ".\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; }  
}  
 
posted @ 2019-11-06 21:48  wswind  阅读(267)  评论(0编辑  收藏  举报