Windows PowerShell で、特定のディレクトリに保存されたイメージを一括コンバートするスクリプトを紹介します。
指定されたディレクトリの指定されたイメージをコンバート
# 変数の定義
[string]$InDir = "D:\Temp\In" # コンバート前のイメージが保存されているディレクトリ
[string]$OutDir = "D:\Temp\Out" # コンバート後のイメージが保存されているディレクトリ
[string]$InExt = "png" # コンバート前のイメージの種類
[string]$OutExt = "jpeg" # コンバート後のイメージの種類
# コンバート前のディレクトリからファイルを一つずつ読み込みコンバートする。
foreach ($File in Get-ChildItem $InDir)
{
$InFile = $File.FullName # コンバート前のファイルのフルファイル名
$OutFile = $inFile
$OutFile = $OutFile.Replace($InDir, $OutDir) # ディレクトリ名を置換
$OutFile = $OutFile.Replace($InExt, $OutExt) # 拡張子を置換
$Work = [System.Drawing.Image]::FromFile($InFile) # コンバート前ファイルの読み込み
$Work.Save($OutFile, $OutExt) # コンバート実施
}