Delete all files of a resolution Apple Photos

Solution 1:

You can identify low-resolution photos in Photos.app using AppleScript and collate them into a single album that would then allow you to select them all in one go for deletion.

Ordinarily, this code snippet (run from inside Script Editor) would find the low-resolution photos (and videos) and put them into a new album called "Low Res":

    tell application "Photos" to add ¬
        (every media item whose ¬
            (height > width and height ≤ 480) or ¬
            (width > height and width ≤ 480)) to ¬
        make new album named "Low Res"

However, on MacOS 10.13 with the latest updates installed, it throws an error, reporting that it can't retrieve the specified album. This is probably a bug in Photos.app.

So, I decided to assign a description to all of these media items instead:

    tell application "Photos" to ¬
        set the description of ¬
            (every media item whose ¬
                (height > width and height ≤ 480) or ¬
                (width > height and width ≤ 480)) to ¬
            "Low Resolution"

    display alert "Done."

Then, within Photos.app, I created a Smart Album with the following search criterion:

Smart Album Criteria in Photos.app on MacOS

After clicking OK, the album was populated by the photos (and videos) that were marked as being of low-resolution.

Now, assuming there's nothing in there you'd like to keep, you would simply press Cmd+A to select all of the items, then Cmd+ to delete them all from the library (it actually moves them to the library's Recently Deleted folder, meaning you can retrieve any items you didn't intend to delete).

A couple of notes:

If you don't want video files to be included in the cull, then use these criteria for the smart album instead:

Smart Album Criteria in Photos.app on MacOS to exclude video files

Note the match selection is set to all. This excludes videos and gives you an album populated only by photos of low resolution.

Finally, bear in mind that the AppleScript has to search through your entire library and compare the height and width of every item it comes across. Depending on your library size, it can take a few minutes.

My Photos.app library has 8000 photos in it and it took about three minutes to on a MacBook 1.2GHz m5 to complete.

If Script Editor times out, wrap the code inside a timeout block and specify a length of time in seconds to allow the code to run to completion:

    with timeout of 300 seconds
        tell application "Photos" to...
        ...etc...
    end timeout

    display alert "Done."