0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windowsスポットライトの画像を保存する

Posted at

説明

  • 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
0
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?