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.
If ('.png', '.jpg', ... -Contains $fileExtention) {...Get-ChildItem *|Where-Object Extension -in '.png','.jpg'orGet-ChildItem * -include '*.png','*.jpg'