Smart image search via Powershell

前端 未结 2 896
挽巷
挽巷 2021-02-06 04:30

I am interested in file searching by custom properties. For example, I want to find all JPEG-images with certain dimensions. Something looks like

Get-ChildItem -         


        
2条回答
  •  盖世英雄少女心
    2021-02-06 04:54

    Here's an alternative implementation as a (almost) one-liner:

    Add-Type -Assembly System.Drawing
    
    Get-ChildItem -Path C:\ -Filter *.jpg -Recursive | ForEach-Object { [System.Drawing.Image]::FromFile($_.FullName) } | Where-Object { $_.Width -eq 1024 -and $_.Height -eq 768 }
    

    If you are going to need to run this command more than once, I would recommend Johannes' more complete solution instead.

提交回复
热议问题