我想將一個 Folder 裡面,所有橫影嘅圖片,
都 Copy 晒落另一個 Folder,
問過 GPT 俾咗下面堆 PS Code 我,
但係明明啲圖片係直影,個 Dimension 都調轉咗。- Add-Type -AssemblyName System.Drawing
- $source = "D:\photos"
- $destination = "D:\landscape"
- $count = 1
- Get-ChildItem -Path $source -Filter *.jpg -Recurse | ForEach-Object {
- $image = [System.Drawing.Image]::FromFile($_.FullName)
- if ($image.Width -gt $image.Height) {
- $newName = "{0:D4}.jpg" -f $count
- $newPath = Join-Path $destination $newName
- Copy-Item $_.FullName -Destination $newPath
- $count++
- }
- }
複製代碼 |