Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5966787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:50:58+00:00 2026-05-22T19:50:58+00:00

I’m writing an applescript to automate some tedious work in Aperture, and I’m having

  • 0

I’m writing an applescript to automate some tedious work in Aperture, and I’m having a hell of a time understanding some of the peculiarities of the language. In particular, I’m having a really difficult time dealing with collections (lists and elements). I’m stumped by object specifiers that include collections and applying commands to elements in a collection. Moreover, I’m confused by strange differences in object specifiers that seem to behave differently when referring to object elements by their class within a class versus, well, let me show you.

Here’s the beginning of a script.

prop Movies : {}

tell Application "Aperture"
     set Movies to every image version whose name of every keywords contains "Movie"
end tell

length of Movies   -- result => 601

The application object in Aperture contains an elements collection of image versions. image version objects contain an elements collection of keywords. keywords are objects/lists with a name and id property.

So the global script property Movies now contains all of the image version objects in my Aperture library that are actually videos. Now, when I try to do this:

repeat with movie in Movies
    log ("Movie name is '" & name of movie & "'.")
    log ("  the class of this object is '" & class of movie & "'.")
end

the output, as expected, is:

Movie name is 'MOV03510.MPG'.
  the class of this object is 'image version'.
Movie name is 'MOV00945'.
  the class of this object is 'image version'.
Movie name is 'MOV03228.MPG'.
  the class of this object is 'image version'.
Movie name is 'MOV02448'.
  the class of this object is 'image version'.
...

However, I’m stuck with how to access an elements collection within those image versions. When I do this:

repeat with movie in Movies

    log ("Movie name is '" & name of movie & "'.")
    log ("  the class of this object is '" & class of movie & "'.")
    set kwnamelist to name of every keyword in movie
    if kwnamelist contains "Movie"
       log ("    Yes, '" & name of movie & "' is indeed a video.")
    end if
end

gives me

find_videos.applescript:1089:1096: script error: Expected class name but found identifier. (-2741)

The error, to me, sounds like applescript is confused by the object specifier name of every keyword in movie. BUT, the reason I’m so confused about this is that if I write this code:

tell Application "Aperture"
    repeat with imageind from 1 to 1000
        set img to item imageind of image versions
        tell me to log ("Image name is '" & name of img & "'.")
        tell me to log ("  the class of this object is '" & class of img & "'.")
        set kwnamelist to name of every keyword in img
        if kwnamelist contains "Movie" 
            tell me to log ("    '" & name of img & "' is actually a video!")
        end if
    end
end tell

then I get the expected output:

...
Image name is 'DSC_4650'.
  the class of this object is 'image version'.
Image name is '104-0487_IMG'.
  the class of this object is 'image version'.
Image name is 'MOV02978.MPG'.
  the class of this object is 'image version'.
    'MOV02978.MPG' is actually a video!
Image name is '108-0833_IMG'.
  the class of this object is 'image version'.

...

Can anyone tell me what’s wrong with my object specifier? Why is it that I can essentially apply get name to every keyword in img when the image version is in one context, but I can’t in a different context? Is there something I’m missing here? Is it that the keyword class is internal to the Aperture application object? How would I specify something like application::keyword if that’s the case?

UPDATE:

I’ve solved this particular problem, but I’d really appreciate it if someone could explain exactly why this solves it. I did this:

tell Application "Aperture"
    repeat with movie in Movies
        tell me to log ("Movie name is '" & name of movie & "'.")
        tell me to log ("  the class of this object is '" & class of movie & "'.")
        set kwnamelist to name of every keyword in movie
        if kwnamelist contains "Movie"
            tell me to log ("    Yes, '" & name of movie & "' is indeed a video.")
        end if
    end
end tell

gives the expected output:

...
Movie name is 'IMG_0359'.
  the class of this object is 'image version'.
    Yes, 'IMG_0359' is indeed a video.
Movie name is 'MOV02921.MPG'.
  the class of this object is 'image version'.
    Yes, 'MOV02921.MPG' is indeed a video.
Movie name is 'MOV02249'.
  the class of this object is 'image version'.
    Yes, 'MOV02249' is indeed a video.
...

It seems like there’s a very peculiar scope issue at work here. Could someone explain to me how keyword objects are in scope in this new version, but out of scope in the previous version where we weren’t in a tell block? I thought that tell blocks were just for directing commands without direct parameters? Do they determine type scope as well? Or is there a command hidden somewhere here in the construction/execution of the object specifier that depends on getting sent to the Application "Aperture" object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:50:59+00:00Added an answer on May 22, 2026 at 7:50 pm

    If I understand the core of your question correctly – because you have solved the practical part, screwy dereferencing, which is a bit of an old chestnut for applescripters – you must only use terminology inside the relevant tell blocks, so if your application (Aperture) supplies the terminology “keyword”, you can’t refer to “keyword” unless you are inside a tell application "Aperture" block.

    OR if for some reason you want to use terminology from a given app without using a tell block, you can wrap your code like this:

    using terms from application "Aperture"
      -- blah blah about 'keyword' and other Aperture terminology
    end using terms from
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.