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 -Path C:\ -Filter *.jpg -Recursive | where-object { $_.Dimension -eq '1024x768' }
I suspect it’s about using of System.Drawing. How it can be done?
Thanks in advance
That’s actually pretty easy to do and your gut feeling about System.Drawing was in fact correct:
Save that as
Get-Image.ps1somewhere in your path and then you can use it.Another option would be to add the following to your
$profile:which works pretty much the same. Of course, add fancy things like documentation or so as you see fit.
You can then use it like so:
Note that you should dispose the objects created this way after using them.
Of course, you can add a custom
Dimensionproperty so you could filter for that: