Club MacMost Exclusive: Finding Duplicate Photos with a Script

I played around with a JXA (JavaScript for Automation instead of AppleScript) script that searches for duplicate photos in your Photos library and marks them with a keyword. It turned out to be pretty simple. But it could be dangerous if you plan to use it to permanently deleted photos.Here is the script text: var Photos = Application("Photos"); Photos.includeStandardAdditions = true; var currentSelection = Photos.selection(); var photoDataList = []; for (var item of currentSelection) { var photoInfo = String(item.date())+" "+String(item.size())+" "+String(item.name()); var isDup = false; for(var i=0;i<photoDataList.length;i++) { if (photoDataList[i] == photoInfo) { isDup = true; break; } } if (isDup) { var keys = item.keywords(); if (keys == null) keys = []; item.keywords = keys.concat(["duplicate"]); } else { photoDataList.push(photoInfo); } }

Note: This is Club MacMost exclusive content. To view this video click the thumbnail below to go to the post as Patreon.com. Once there you will be able to view the video as long as you are logged into your Patreon account and a current supporter of MacMost at the "Club MacMost" or higher level.