This may be an Apple script, a terminal script or something else? I've never scripted in MacOS before as all my programming has been in Windows (forgive me).
I am currently organizing a photo library (outside of Photos) of some 120,000+ photos with some 50,000+ duplicates in it. I'm using Photo Sweeper to help identify the duplicates but when it deletes it only removes the photo file (jpg, heic, raw etc). If the file has a sidecar (aae, xmp) it is left and orphaned. I will have 10s of thousands of orphaned sidecar files once I am done with this clean up.
I'm trying to find a script or a process that will allow me to find and deleted all .xmp and .aae sidecar files in a folder if there is no matching file name (one without a associated .xmp or .aae extension). The matching file may be a .jpg, .heic, .raw, .rw2, .png etc.
For the life of me, while I work in scripts all the time for work in Windows, on MacOS I can't figure out how to start with this. I'm thinking this may be an Apple script, or perhaps something UNIX related to run in terminal?
My Applescript knowledge is limited to 30 minutes of web browsing so far.. Some pointers in the right direction would really help me out. I'm thinking of a script along these lines..
Obviously this code won't work as it is just conceptual but any guidance or a better way to do this would be much appreciated.
I am currently organizing a photo library (outside of Photos) of some 120,000+ photos with some 50,000+ duplicates in it. I'm using Photo Sweeper to help identify the duplicates but when it deletes it only removes the photo file (jpg, heic, raw etc). If the file has a sidecar (aae, xmp) it is left and orphaned. I will have 10s of thousands of orphaned sidecar files once I am done with this clean up.
I'm trying to find a script or a process that will allow me to find and deleted all .xmp and .aae sidecar files in a folder if there is no matching file name (one without a associated .xmp or .aae extension). The matching file may be a .jpg, .heic, .raw, .rw2, .png etc.
For the life of me, while I work in scripts all the time for work in Windows, on MacOS I can't figure out how to start with this. I'm thinking this may be an Apple script, or perhaps something UNIX related to run in terminal?
My Applescript knowledge is limited to 30 minutes of web browsing so far.. Some pointers in the right direction would really help me out. I'm thinking of a script along these lines..
AppleScript:
tell application "Finder"
set search_folder to (choose folder)
set sidecar_list to files in folder search_folder whose name extension is in ["xmp", "aac"]
repeat with i from 1 to (count sidecar_list)
set sidecar_name as name of item i of sidecar_list
set photo_list to files in search_folder whose name is sidecar_name and name extension is not in ["xmp", "aac"]
if (count photo_list)=0 then delete item i of sidecar_list
end repeat
end tell
Obviously this code won't work as it is just conceptual but any guidance or a better way to do this would be much appreciated.