Created
August 8, 2020 15:07
-
-
Save zplume/884416cb7f9bdbbb99fc67e965537829 to your computer and use it in GitHub Desktop.
Revisions
-
zplume created this gist
Aug 8, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ $imagePath = "$home\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\*" $destinationPath = "$home\OneDrive\Pictures\Lock screen" Add-Type -AssemblyName System.Drawing # get images from lock screen folder $items = Get-ChildItem -Path $imagePath foreach($item in $items) { $fileName = $item.Name # skip small images/icons if($item.Length -lt 100000) { Write-Host " Skipped " -b Red -f Black -NoNewline Write-Host -f White " $($fileName).jpg" continue } # get image dimensions $image = New-Object System.Drawing.Bitmap $item.FullName $imageWidth = $image.Width $imageHeight = $image.Height $image.Dispose() # prevent file lock # separate images into Landscape/Portrait destination sub-folders # note: the script assumes these folders already exist if($imageWidth -gt $imageHeight) { $newPath = "$destinationPath\Landscape\$($fileName).jpg" } else { $newPath = "$destinationPath\Portrait\$($fileName).jpg" } # only copy files that haven't # already been copied if(!(Test-Path $newPath)) { Copy-Item -Path $item.FullName -Destination $newPath Write-Host -b Green -f Black " Copied " -NoNewline } else { Write-Host -b Yellow -f Black " Exists " -NoNewline } Write-Host -f White " $($fileName).jpg" }