我想将一个 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++
- }
- }
复制代码 |