I had a project where I took a picture from a security camera every 15 minutes in order to build a timelapse. The project lasted almost a year so I didn’t have a good way to set the day/night schedule as the seasons changed. I ended up taking pictures every 15 minutes for the whole project.

In order to build the final project I needed to remove all the dark images. I certainly wasn’t going to go through the entire folder contents and erase a group of pictures per night. In comes the utility identify from ImageMagick. This utility gives you the mean of the image so we can find the darker images.

$pictures = gci -Filter *.jpg -Recurse | Select -ExpandProperty FullName

foreach ($i in $pictures) {
    $mean = identify.exe -quiet -format "%[mean]" "$i"
    if ($([int]$mean) -le 10000) {
        Remove-Item "$i" -Force