How to do multiple shell scripts in AppleScript

I got some solutions from previous posts on how to run sudo in Applescript, but there is still some minor syntax issues when I try to get to the destination directory. Usually in shell script I just type

cd directory-destination
...

in several lines to batch process those commands, but when I work with applescript, if I do do shell script for every "cd" command, instead of getting an overall result, I would get intermediate results individually.

I read doc and learned that there might be a way to put commands together by using the & sign?

Message was edited by: ttback

iMac, Mac OS X (10.5.5)

Posted on Sep 7, 2010 11:14 AM

Reply
1 reply

Sep 7, 2010 11:57 AM in response to ttback

An individual do shell script command runs in its own shell, so to perform multiple commands within that shell you need to combine them into a single statement. You can use the ampersand '&' operator to concatenate text strings, and the semicolon ';' to separate the commands, for example:
set theFolder to "/Applications"
do shell script "cd " & theFolder & "; ls -l ."
See the technical note do shell script in AppleScript.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to do multiple shell scripts in AppleScript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.