用DeepSeek写了个脚本,超级方便。
使用前需要安装 https://imagemagick.org/script/download.php
# HEIC to JPEG Conversion Script
# Check if ImageMagick is installed (required for HEIC conversion)
if (-not (Get-Command magick -ErrorAction SilentlyContinue)) {
Write-Host "ImageMagick is required for HEIC conversion. Please install it first." -ForegroundColor Red
Write-Host "You can install it via Chocolatey: 'choco install imagemagick'" -ForegroundColor Yellow
exit 1
}
# Create 'converted' directory if it doesn't exist
$convertedDir = Join-Path -Path $PWD.Path -ChildPath "converted"
if (-not (Test-Path -Path $convertedDir)) {
New-Item -ItemType Directory -Path $convertedDir | Out-Null
}
# Get all HEIC files in current directory
$heicFiles = Get-ChildItem -Filter *.HEIC
if ($heicFiles.Count -eq 0) {
Write-Host "No HEIC files found in the current directory." -ForegroundColor Yellow
exit 0
}
# Convert each HEIC file to JPEG
foreach ($file in $heicFiles) {
$jpegName = [System.IO.Path]::ChangeExtension($file.Name, "jpeg")
$jpegPath = Join-Path -Path $PWD.Path -ChildPath $jpegName
Write-Host "Converting $($file.Name) to $jpegName..." -ForegroundColor Cyan
# Convert using ImageMagick
magick $file.FullName $jpegPath
if ($LASTEXITCODE -eq 0) {
# Move original HEIC to converted folder
$destination = Join-Path -Path $convertedDir -ChildPath $file.Name
Move-Item -Path $file.FullName -Destination $destination -Force
Write-Host "Conversion successful. Moved original to converted folder." -ForegroundColor Green
} else {
Write-Host "Conversion failed for $($file.Name)" -ForegroundColor Red
}
}
Write-Host "`nConversion process completed." -ForegroundColor Green
Write-Host "Converted $($heicFiles.Count) HEIC files to JPEG." -ForegroundColor Green


