I am working on a script that modifies images in a folder, for the most part, it is done I use Get-ChildItem with the directory.
So what I am currently doing is making a variable called
$fileExtension = [IO.Path]::GetExtension($files[$counter].Name)
with an if statement that is like:
if($fileExtension -eq '.png' or
$fileExtensiono -eq '.jpg'. . . )
Is there a better way of doing this? I really want it to execute this function that modifies images if the file is an image, a folder could contain other items such as a zip which will crash the script if it picks up on it.
try Something like this:
get-childitem 'c:\temp\*' -file -include '*.png', '*.jpg'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With