Skip to content

Instantly share code, notes, and snippets.

@CaptainHypertext
Last active March 19, 2019 13:29
Show Gist options
  • Save CaptainHypertext/216b14d8a3b797590d77a03cf28f929b to your computer and use it in GitHub Desktop.
Save CaptainHypertext/216b14d8a3b797590d77a03cf28f929b to your computer and use it in GitHub Desktop.
Windows Spotlight image saver (powershell)
<#
PowerShell Script that saves Windows Spotlight images to a specified folder. Good for automatic, new wallpaper.
Last revision: 3/17/2019
#>
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing.Image")
$storage_path = "F:\Pictures\Wallpapers\Windows Spotlight"
$assets_path = $env:LOCALAPPDATA + "\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
$save_width = 1920;
$save_height = 1080;
$extension = "jpg"
$files = Get-ChildItem $assets_path;
if( -Not (Test-Path $storage_path) ) {
mkdir($storage_path);
}
foreach($file in $files) {
if($file) {
$img = [System.Drawing.Image]::FromFile($file.FullName)
$new_path = "$($storage_path)\$($file.Name).$($extension)"
if( $img.Width.Equals($save_width) -AND $img.Height.Equals($save_height) -AND !(Test-Path $new_path) ) {
Copy-Item $file.FullName -Destination $new_path
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment