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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:09:04+00:00 2026-06-16T07:09:04+00:00

I’m new to applescripts and I’m trying to automate a process, but how do

  • 0

I’m new to applescripts and I’m trying to automate a process, but how do you change directory through the script when there are spaces inside the directory? My commands should be correct but a syntax error keeps popping up:

Expected “"” but found unknown token.

Here is my script:

tell application "Terminal"
activate
do script "cd ~/Pictures/iPhoto\ Library"
end tell

I don’t understand where it is wrong. It works fine on my terminal.

Thanks a bunch guys!!

UPDATE: this worked best!!

# surround in single quotes
tell application "Terminal"
    activate
    do script "cd  '/Users/username/Pictures/iPhoto Library'"
end tell
  • 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-06-16T07:09:06+00:00Added an answer on June 16, 2026 at 7:09 am

    The are a few ways.

    # escape the quotes with a backslash. AND Escape the first backslash for Applescript to accept it.
    tell application "Terminal"
        activate
        do script "cd ~/Pictures/iPhoto\\ Library"
    end tell
    
    # surround in double quotes and escape the quotes with a backslash. 
    tell application "Terminal"
        activate
        do script "cd \"/Users/username/Pictures/iPhoto Library\""
    end tell
    
    # surround in single quotes using quoted form of 
    tell application "Terminal"
        activate
        do script "cd " & quoted form of "/Users/username/Pictures/iPhoto Library"
    end tell
    # surround in single quotes
    tell application "Terminal"
        activate
        do script "cd  '/Users/username/Pictures/iPhoto Library'"
    end tell
    

    Also I do not thing the tild will expand when you use the quotes on the whole path.
    So you will need to get the user name another way.

    Examples:

    # inserting the user name. And surrond in brackets so the name and path are seen as one string before the quotes are added
    set whoami to do shell script "/usr/bin/whoami"
    tell application "Terminal"
        activate
        do script "cd /Users/" & quoted form of whoami & "/Pictures/iPhoto\\ Library"
    end tell
    
    
    
    tell application "System Events" to set whoami to name of current user
    # inserting the user name. And surrond in brackets so the name and path are seen as one string before the quotes are added
    tell application "Terminal"
        activate
        do script "cd /Users/" & quoted form of (whoami & "/Pictures/iPhoto Library")
    end tell
    

    As you can see there is more than one way to do any of this.

    Or just quote the directory part.

    Example.

    tell application "Terminal"
        activate
        do script "cd ~" & quoted form of "/Pictures/iPhoto Library"
    end tell
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to loop through a bunch of documents I have to put
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

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.