説明
- Windowsスポットライトの画像を保存するスクリプトです。
- スポットライトのディレクトリ内の100KB以上、横長の画像をPictureフォルダにコピーします。
- スポットライトのディレクトリ内は定期的に削除されているようなので、スタートアップ時の実行ディレクトリに入れておくと定期的にクロールして保存してくれると思います。
- また整理します。
スクリプト
savephoto.bat
<# : Batch portion (PowerShell multi-line comment)
@echo off & setlocal
for %%F in ( %homedrive%%homepath%\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\* ) do (
if %%~zF GEQ 100000 (
call :isLandscape %%F && (
echo copy_%%F_to_%homedrive%%homepath%\Pictures\%%~nF.jpg
copy %%F %homedrive%%homepath%\Pictures\%%~nF.jpg
)
)
)
goto :EOF
:isLandscape <imgfile>
rem # function sets errorlevel 0 if landscape, 1 if portrait or square
setlocal disabledelayedexpansion
set "img=%~1"
powershell -noprofile -noninteractive "iex (${%~f0} | out-string)"
endlocal & exit /b %errorlevel%
: end batch / begin PowerShell hybrid code #>
add-type -Assembly System.Windows.Forms
$size = [Drawing.Image]::FromFile((gi $env:img)).Size
exit ($size.Width -le $size.Height) # 0 = false, 1 = true