Skip to main content

⚠️ Please note that this topic or post has been archived. The information contained here may no longer be accurate or up-to-date. ⚠️

Simple question

Comments

3 comments

  • Eric Valk
    Capture One gets upset if you delete the collection which is the current collection. And the errorr message is actually incorrect and misleading.

    On the other hand, collection 1 is "All Images" (which can never be deleted, and is always present).
    One strategy is to select the album to be deleted, get the AppleScript reference to that collection, select any other collection (All Images is always there - so use that), and then delete the collection that was selected.

    This code works. Select the collection which is to be deleted, and run the script.

    tell application "Capture One 11" to tell (get current document)
    set theOldCollection to get current collection
    set the current collection to collection 1
    delete theOldCollection
    end tell

    On the other hand if you want to delete some collection which you know the name of, there is no need to select it.
    Assuming that the current Project or Group contains an album named "Untitled", this works

    tell application "Capture One 11" to tell (get current document) to tell (get current collection)
    delete collection "Untitled"
    end tell

    However, if the collection to be deleted is at the top level (not inside any Project or group) then this is needed:

    tell application "Capture One 11" to tell (get current document)
    delete collection "Untitled"
    end tell

    Filtering requires a little trick to work on Capture One collections. For example, the first and second lines work, the third does not:
    tell application "Capture One 11" to tell (get current document) to tell (get current collection)
    get collection "Untitled"
    get first collection whose name is "Untitled"
    get collection whose name is "Untitled" -- creates an error
    end tell

    It's a good idea to test your code with "get" before using "delete"
    0
  • FirstName LastName
    Thanks a lot. Scripting is no easy to me. I have programming for a lots of years but allway in a structured languages.
    I will try all yours pieces of source to understand this kind of programming.
    Can You recommend me useful and interesting resources to learn scripting.
    Above all I learn by seeing examples to do concrete things. From this I find rather little. Especially orienting it to Capture One
    Again, thanks to get the time to answer me.
    0
  • Eric Valk
    Well, first of all, always check the AppleScript dictionary for Capture One carefully.

    Script Editor has a useful link to the AppleScript language guide - from there - Index, click on a letter, find a command or topic.

    The MacScripter forum has some of the smartest AppleScript brains on the planet. There is a forum, shared code and tutorials.

    Some times I just use google search to find possible answers. Quite often find good answers in Stack Exchange.

    Script Editor has poor debug features. So write-test-write-test in small pieces.

    It’s very useful to check the “replies†section of the Script Editor log window. It shows the real reply from the application.

    It’s easy to comment out one or two lines that shouldn’t run. But to put a larger section “on holdâ€, surround it with

    If false then
    ...............
    end if


    Check out my other postings, like the one on “Image Search†for lots of examples on interacting with CO.
    0

Please sign in to leave a comment.