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 6610175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:48:23+00:00 2026-05-25T19:48:23+00:00

Im building an app for learning purposes of using applescript to send multiple commands

  • 0

Im building an app for learning purposes of using applescript to send multiple commands during an action. Below is the code I’m messing with but I have stripped out the actions in between the “” and replaced them with numbers. Everything works fine in applescript but making this into an NSApplescript initwithsource: line has been a bother.

tell application "Terminal"
    activate
    set currentTab to do script "1"
    do script "2" in currentTab
    do script "3" in currentTab
    do script "4" in currentTab
    delay 0.5
    tell application "Finder" to set visible of process "Terminal" to false
end tell

What is the best way to combine this applescript into a single line? Thanks!

  • 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-25T19:48:24+00:00Added an answer on May 25, 2026 at 7:48 pm

    “What is the best way to combine this applescript into a single line?”

    Use AppleScript? 😀

    First, in AppleScript Editor, open the Preferences window and click the option to Show Script menu in menu bar.

    Then choose Open Scripts Folder from the script menu item up in the upper right of the screen.

    Create a new AppleScript .scptd document with the following script:

    tell application "AppleScript Editor"
        set string_ to text of first document
    
        -- make a list with each line of the script
        set stringLines to paragraphs of string_
        set originalDelims to AppleScript's text item delimiters
    
        -- add newlines 
        set AppleScript's text item delimiters to "\\n"
    
        -- now combine the items in the list using newlines
        set stringNewlines to stringLines as string
    
        set AppleScript's text item delimiters to "\""
        set stringNewlines to text items of stringNewlines
        set AppleScript's text item delimiters to "\\\""
        set stringNewlines to stringNewlines as string
    
        set AppleScript's text item delimiters to originalDelims
        set stringNewlines to "@\"" & stringNewlines & "\""
    
        set the clipboard to stringNewlines
    end tell
    

    (Note that this script isn’t perfect: it works fine for simple scripts like the one you provided, but isn’t able to convert itself).

    Save that as a script in the Scripts folder you revealed earlier.

    Then open your script document you want to convert and make it the front document in AppleScript Editor. Then invoke the conversion script by choosing it from the Script menu.

    Given the script you provided, it should produce the following constant NSString:

    @"tell application \"Terminal\"\n   activate\n  set currentTab to do script \"1\"\n do script \"2\" in currentTab\n do script \"3\" in currentTab\n do script \"4\" in currentTab\n delay 0.5\n tell application \"Finder\" to set visible of process \"Terminal\" to false\nend tell\n"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting started learning rails. I am building my first app using
I am learning Spring and building a sample app. I am getting the error:
Im learning Rails by building apps. I want to make my first authenticated app:
So I'm building an app that uses win32's SendMessage as IPC. I'm using FindWindow
I'm building an app in PHP and I'm using the data mapper pattern for
Thanks for looking. I am learning rails and am building a web app. I
I am learning Python and building my first web app. I have been going
I have been slowing learning and building my first android app. I'm VERY new
I've been learning and building JSONP Web services using WCF on fx3.5. You can
I'm building app using GAE and wanted to use Django for that. Which patch

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.