LoginSignup
0
1

More than 5 years have passed since last update.

ImageMagick を使ってファイルをjpgに一括変換 (PowerShell)

Last updated at Posted at 2018-06-29

手早く作ったものをメモ。ググって出てきた内容そのままでできなかったので。
PowerShell で Windows 向け。
ImageMagick自体は https://www.imagemagick.org/script/download.php からImageMagick-7.0.8-3-Q16-x64-dll.exeをDLして確認しました。

# 入力:フォルダパス
# 新しいフォルダを作ってjpgファイルを書き出す

# 新しいフォルダ
$oldDirectoryName = $args[0]
$newDirectoryName = $oldDirectoryName + "-jpg"
New-Item $newDirectoryName -ItemType Directory

# ファイル変換
$files = Get-ChildItem $oldDirectoryName | Where-Object { ! $_.PSIsContainer }
foreach ($item in $files) {
    $jpgFilename = Join-Path $newDirectoryName ($item.BaseName + ".jpg")
    magick convert $item.FullName $jpgFilename
}
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