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

  • SEARCH
  • Home
  • 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 952965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:58:32+00:00 2026-05-15T23:58:32+00:00

Is there a way to do a remote copy within a container from Scripting

  • 0

Is there a way to do a remote copy within a container from Scripting Bridge? In AppleScript, this looks like “copy [element] of [container] to [location in container]”. For example, in the context of a tell to a TextEdit document, you can “copy first paragraph of its text to end of its text” to copy the first paragraph to the end of the document while preserving all formatting.

Is there any way to do with from Objective-C using Scripting Bridge?

I tried something like this:

SBObject* foo = [container objectAtIndex: 0];
[container addObject: foo];

And got a message “can’t add an object that already exists.” on the console; it appears that addObject and the various replace* methods only work when you’re building a new SBObject instance and inserting it.

  • 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-15T23:58:32+00:00Added an answer on May 15, 2026 at 11:58 pm

    When the second parameter to AppleScript’s built-in copy command is an application reference, AppleScript ‘helpfully’ aliases to an application duplicate or set command, depending on whether the first parameter is another reference or not. To avoid confusion, it’s best to use duplicate or set explicitly when dealing with scriptable apps in AppleScript.

    As for SB, you would need to look for a duplicate... method in the header file. Be aware that SB’s duplicate command is semi-crippled (SB has quite a few shortcomings) since it can only deal with a single object at a time. Most applications will allow you to manipulate multiple objects in a single command (caveat any bugs in their scripting support), e.g. AppleScript will let you say:

    tell application "iTunes"
        duplicate (every track whose artist is "Foo") to (playlist "Bar")
    end tell
    

    but SB won’t; instead you have to extract a list of single references and iterate over those, processing them one at a time. Makes your code rather longwinded, and can be very inefficient if you’ve a large number of objects elsewhere.

    Another option is objc-appscript, which does all this stuff correctly and is much less prone to application compatibility issues in general (‘quirk-for-quirk compatibility’, as Matt Neuburg puts it). Plus you get ASTranslate, which converts AppleScript commands to the equivalent Python/Ruby/ObjC syntax – very handy when figuring out how to phrase a command correctly:

    #import "ITGlue/ITGlue.h"
    ITApplication *itunes = [ITApplication applicationWithName: @"iTunes"];
    ITReference *ref = [[itunes tracks] byTest: [[ITIts artist] equals: @"Foo"]];
    ITDuplicateCommand *cmd = [[ref duplicate] to: [[itunes playlists] byName: @"Bar"]];
    id result = [cmd send];
    

    Yet another option, if you’re on 10.6, would be to use the AppleScriptObjC bridge, which allows you to combine AS and ObjC in the same program without any of that nasty NSAppleScript nonsense. That would allow you to use AppleScript for what it’s best at (communicating with other apps) and ObjC for everything else. Official documentation is limited, but a web-search should throw up various third-party resources. MacScripter.net might be a good place to start – in addition to the ASOC forum, Craig Williams posted a series of tutorials a while back.

    (BTW, Craig also contributed a chapter about ASOC to the third edition of Apress’s Learn AppleScript, which I co-wrote, and which includes lots of information on application scripting principles and practices, including clarification of set/duplicate/copy.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 467k
  • Answers 467k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you are mistaken. The dr is a reference… May 16, 2026 at 2:02 am
  • Editorial Team
    Editorial Team added an answer Creating the KalView in the XIB instead of creating it… May 16, 2026 at 2:02 am
  • Editorial Team
    Editorial Team added an answer Check the mkdtemp function here. May 16, 2026 at 2:02 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.