power shell 问题

我想将一个 Folder 里面,所有横影嘅图片,
都 Copy 晒落另一个 Folder,
问过 GPT 俾咗下面堆 PS Code 我,
但系明明啲图片系直影,个 Dimension 都调转咗。
  1. Add-Type -AssemblyName System.Drawing

  2. $source = "D:\photos"
  3. $destination = "D:\landscape"
  4. $count = 1

  5. Get-ChildItem -Path $source -Filter *.jpg -Recurse | ForEach-Object {
  6.     $image = [System.Drawing.Image]::FromFile($_.FullName)
  7.     if ($image.Width -gt $image.Height) {
  8.         $newName = "{0:D4}.jpg" -f $count
  9.         $newPath = Join-Path $destination $newName
  10.         Copy-Item $_.FullName -Destination $newPath
  11.         $count++
  12.     }
  13. }
复制代码

本帖最后由 javacomhk 于 2023-5-29 10:58 编辑

powershell 嘅问题你问 Bing 嘅 AI 会好的

TOP