Skip to content

Instantly share code, notes, and snippets.

@adilio
Last active May 7, 2023 16:15
Show Gist options
  • Save adilio/b34ee72893e360470fa7d8d8090e20aa to your computer and use it in GitHub Desktop.
Save adilio/b34ee72893e360470fa7d8d8090e20aa to your computer and use it in GitHub Desktop.
Copies Windows Spotlight Images
<#
Copy-SpotlightImages.ps1
20181018 - 4dilio
Improved by https://www.reddit.com/user/Lee_Dailey/
Makes a copy of Windows Spolight images for your lockscreen,
and saves them to your $env:USERPROFILE\Pictures\Spotlight directory.
If the directory doesn't exist, it is created. Any image larger than
100 KB is copied, as some images in this folder are not wallpaper.
Also, files are renamed with date-stamp, along with first 8 charaters
of filename. This is just to help in sorting.
#>
$ProfileDir = $env:USERPROFILE
$SourceDir = "$ProfileDir\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
$DestinationDir = "$ProfileDir\Pictures\Spotlight"
If ( -Not (Test-Path -LiteralPath $DestinationDir)) {
New-Item -ItemType Directory -Force -Path $DestinationDir
}
$SpotFiles = (Get-ChildItem -LiteralPath $SourceDir |
Where-Object {$_.Length -ge 100KB})
Foreach ($SF_Item in $SpotFiles) {
$TimeStamp = $SF_Item.CreationTime.ToString('yyyy-MM-dd_HH-mm-ss')
$NewFileName = '{0}_-_{1}.jpg' -f $TimeStamp, $SF_Item.Name.SubString(0, 8)
$FullNewFileName = Join-Path -Path $DestinationDir -ChildPath $NewFileName
Copy-Item -LiteralPath $SF_Item.FullName -Destination $FullNewFileName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment