作者: ghostkcleung 時間: 2023-5-29 18:51 標題: power shell 問題
我想將一個 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++
- }
- }
作者: javacomhk 時間: 2023-5-29 18:56
本帖最後由 javacomhk 於 2023-5-29 10:58 編輯
powershell 嘅問題你問 Bing 嘅 AI 會好的
