Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following code to purge a directory recursively does not work because I cannot get past the Application Support folder.

    do shell script "rm -r ~/Library/Application\ Support/Google/Chrome/Default/Pepper Data/Shockwave Flash"
end try
  • If I use ~/Library/Application Support/Google... nothing happens. Which is expected.
  • If I use ~/Library/Application\ Support/Google... I cannot save the script due to the error message: Syntax Error Expected “"” but found unknown token.

How can I work around this error?

share|improve this question
up vote 7 down vote accepted


set pathwithSpaces to "/Users/John/Desktop/This is a test.docx"
do shell script "rm -r " & quoted form of pathwithSpaces
share|improve this answer
Iz works1111 Thank You :) – gentmatt Feb 21 '13 at 18:31

You have to double the backslashes and also escape the other spaces:

do shell script "rm -r ~/Library/Application\\ Support/Google/Chrome/Default/Pepper\\ Data/Shockwave\\ Flash"

Or escape the path some other way:

do shell script "rm -r ~/'Library/Application Support/Google/Chrome/Default/Pepper Data/Shockwave Flash'"

quoted form of replaces ' with '\'' and surrounds the string with single quotes, so it doesn't work with paths that start with ~/.

share|improve this answer
This is even better! Thanks – gentmatt Feb 22 '13 at 7:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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