Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A small PowerShell script to save Windows 10 lock screen images to a more accessible location.
$files = gci $Env:LocalAppData\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets |
where Length -gt 1kb
if ($files) {
$shell = New-Object -ComObject Shell.Application
$folder = "$Env:USERPROFILE\Pictures\Spotlight"
if (!(Test-Path $folder)) { mkdir $folder }
$files | % {
$_ | Copy-Item -Destination $folder\$_.jpg
Get-Item $folder\$_.jpg
} | % {
$namespace = $shell.namespace($folder)
$item = $namespace.ParseName($_.Name)
$size = $namespace.GetDetailsOf($item, 31)
if ($size -match '(\d+) x (\d+)') {
$width = [int]($Matches[1])
$height = [int]($Matches[2])
}
if (!$size -or $width -lt 500 -or $height -lt 500) {
Remove-Item $_
}
}
}
@joaopaulo1511

This comment has been minimized.

Copy link

@joaopaulo1511 joaopaulo1511 commented May 4, 2019

Line 5 can be changed to $Folder = [ System.Environment ]:: GetFolderPath('MyPictures') + '\Spotlight' ;, so even if the user change the Pictures location it will save correctly.

@The-algar

This comment has been minimized.

Copy link

@The-algar The-algar commented Apr 17, 2020

thanks for this
works perfectly well
well done

@Numenor65

This comment has been minimized.

Copy link

@Numenor65 Numenor65 commented Nov 6, 2020

Thank you so much! The script not only copies the files and adds the file extension, but also selects only those images that are likely to be a desktop wallpaper!

@ChavezTheresa

This comment has been minimized.

Copy link

@ChavezTheresa ChavezTheresa commented Mar 8, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment