Hello, I'm looking to create a Powershell script that will allow me to process images based on their file size: any image that comes in over 1 MB gets processed, the rest get ignored. Unfortunately I'm having a bit of trouble integrating NConvert with Powershell, and I'm honestly not sure if this is due to my relative lack of Powershell knowledge or if there really is some issue with NConvert and Powershell (and as such if this is the right place to be asking).
My code is as follows:
Code: Select all
$Dir = "C:\Users\Me\Desktop\Test folder"
$SizeMax = 1000 #KB
# Resize files larger than the $SizeMax
Get-ChildItem -Path $Dir -Recurse | Where { $_.Length / 1000KB -ge $SizeMax } | nconvert -rflag decr -resize 50% 50% -overwrite "C:\Users\Me\Desktop\Test folder\*.jpg"
This is the only way I could get it to work, as adding the $Dir at the end of the NConvert segment caused it to error out. However, running this code doesn't modify based on the file size, it just processes everything in the folder.
Any help would be appreciated, and I do apologize if this is the wrong place to be asking. Thank you!