I am beginner to the Mac command line interface.

For example I want to go to directory "how are you".

But when I type cd how are you, it is avoided. When I change the name to be without space, howareyou to the directory, it works. Any help?

And also how to create an AppleScript script to go to particular a directory?


3 Answers 3

cd 'how are you'


cd how\ are\ you
  • You are welcome. Try: google.com/search?q=applescript+tutorial Nov 2, 2009 at 9:18
  • hi i want to go to cd \Desktop\senthilmuthu\SenthilmuthuSoftwares\check this says no directory...any help
    – senthilmuthu
    Nov 2, 2009 at 12:24
  • 2
    This is not \ but / This is not /Desktop/... but ~/Desktop/...
    – mouviciel
    Nov 2, 2009 at 13:46
  • Does the standard Unix way of typing %20 instead of space also work?
    – bert
    Nov 2, 2009 at 16:56
  • 2
    @bert, using %20 is not a standard Unix way. That is "percent-encoding", as used in URLs: en.wikipedia.org/wiki/Percent-encoding
    – Arjan
    Nov 2, 2009 at 17:20

And to avoid problems, use Tab to automatically complete the name for you. Like if you have three directories in your home folder, ~/:

  • "how are you"
  • "how are we"
  • "how is she"


  • type "cd ~/h", press Tab; this yields "cd ~/how\" and a beep, telling you there's more
  • optionally: press Tab again, to see the list of matching names
  • next, type "a", press Tab; this yields "cd ~/how\ are\" and a beep
  • optionally: press Tab again, to see the list of matching names
  • next, type "y", press Tab; this yields "cd ~/how\ are\ you/"

(Funny: the rendering of the backtick is slightly different in text and in lists. Favouring lists then...)


If you simply want an AppleScript to change it's current working directory, it isn't possible for the entire script as do shell script "uses a new shell process, so state such as changes to variables and the working directory is not saved from one to the next." (Source)

do shell script 'cd /PATH/TO/DIRECTORY/; more commands here'

If you want to use AppleScript to open up and change to the directory in Terminal:

tell application "Terminal"
    do script "cd /PATH/TO/DIRECTORY"
end tell
  • I doubt the first really changes the working directory of the AppleScript? osascript -e 'do shell script "cd ~/Desktop/"' -e 'do shell script "pwd"' (That second example works fine though; osascript -e 'tell application "Terminal"' -e 'activate' -e 'do script "cd /PATH/TO/DIRECTORY"' -e 'end tell')
    – Arjan
    Nov 2, 2009 at 17:09
  • @Arjan van Bentem - I've added some clarification and a correction. Thanks!
    – Chealion
    Nov 2, 2009 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.