How can I iterate over the media items of an album in Photos.app?
By copying and editing online code, I got this far:
for (const album of Application("Photos").albums()) {
console.log("Processing album '" + album.name() + "'")
for (var idx in album) {
console.log(idx)
}
}
However, this doesn't work. I know that each album in Application("Photos").albums()
is a container, but I couldn't find an example how to iterate over its content using javascript.
In other code, I have already created a javascript Map
where each key is the filename(+size+ratio) and it contains lists of duplicates (all but one to be deleted).
Iterating through the albums, I want to extract the properties of the media items to check whether an item is to be deleted and if yes, replace them with the non-deleted duplicates.
Any help or pointers to examples greatly appreciated!
console.log(Application("Photos"))
output?console.log(Application("Photos"))
which results inError -2700: Script error.
. However, I think I found the answer to my original question, which I will post in a minute...console.log()
valid inside of Script Editor? Doesn't work for me.console.log("Hello world")
. Does it work?