0

So far I have:

    do shell script {var}
    "if [[ ! -e /$var/ ]]; then
    mkdir -p $var
    fi"

I am getting an error of "Command not found"

I know I need to escape something, I'm just not sure where.

Var needs to be passed to the shell command, and create the directory in the specified folder if it doesn't already exist.

1 Answer 1

1

All you need is, e.g.:

set var to "/path/to/directory/subdirectory"
do shell script "mkdir -p " & var's quoted form

You do not need to test whether of not it already exists because of the use of the -p option with the mkdir command.

From the manual page for mkdir:

-p      Create intermediate directories as required.  If this option is not specified, the full path
        prefix of each operand must already exist.  On the other hand, with this option specified, no
        error will be reported if a directory given as an operand already exists.  Intermediate
        directories are created with permission bits of rwxrwxrwx (0777) as modified by the current
        umask, plus write and search permission for the owner.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.