LoginSignup
0
1

More than 3 years have passed since last update.

WindowsのSpotlight画像を各種コンソールやエディタの背景に設定する

Posted at

なんとなく日替わりの背景が欲しくなって、PowershellでSpotlight画像を拾ってくるスクリプトを作成した

spotlight.ps1
$spotlightPath = "${env:LOCALAPPDATA}\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
# _cw5n1h2txyewyはWindows 10のマイナーバージョンの違いで変化する場合あり
$outputPath = "${env:USERPROFILE}\Pictures\Spotlight" # 任意のパス
$filesize = "400kb" # ファイルサイズフィルター
$num = 5 # 出力画像数
$filenamePrefix = "" # 出力ファイル名のプレフィックス

cd $spotlightPath
$shuffled = dir * | ? {$_.Length -gt $filesize} | % { $_.Name } | sort -prop @{Exp={[Guid]::NewGuid()}}

for ($i=0; $i -lt $num; $i++){
  cp $shuffled[$i] "$outputPath\$filenamePrefix$i.jpg"
}

上記SpotlightPathにはSpotlightの背景画像以外の画像も含まれていたため、ファイルサイズでフィルタをかける必要がある
400kbは適当。要調整。
0.jpg, 1.jpg, ... のように出力されるので、それぞれのソフトで別の背景を設定できる。

image.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1