Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript "do shell script" variables

Hi


I'm trying to do an AppleScript and inside it run a shell script action. Something of what should be written in the shell script are variables asked before.

How can I write in the shell script variables?


Here's my script:

set sourceFolder to (choose folder with prompt "Scegli la cartella sorgente:")

set targetFolder to (choose folder with prompt "Scegli la cartella da sincronizzare:")

display dialog "Stai per sincronizzare le due cartelle selezionate, l'operazione è irreversibile. Sei sicuro?" buttons {"Annulla", "Continua"} default button 1

if button returned of result is "Continua" then

do shell script "rsync -vaE --delete [HERE GO sourceFolder VARIABLE] [HERE GO targetFolder VARIABLE]"

else

error "Operazione annullata dall'utente" number -128

end if

Posted on Jul 11, 2014 8:07 AM

Reply
Question marked as Best reply

Posted on Jul 11, 2014 8:11 AM

Here:


set sourceFolder to (choose folder with prompt "Scegli la cartella sorgente:")

set targetFolder to (choose folder with prompt "Scegli la cartella da sincronizzare:")

display dialog "Stai per sincronizzare le due cartelle selezionate, l'operazione è irreversibile. Sei sicuro?" buttons {"Annulla", "Continua"} default button 1

if button returned of result is "Continua" then

do shell script "rsync -vaE --delete " & quoted form of POSIX path of sourceFolder & " " & quoted form of POSIX path of targetFolder

else

error "Operazione annullata dall'utente" number -128

end if


(109307)

2 replies
Question marked as Best reply

Jul 11, 2014 8:11 AM in response to Matteo_999

Here:


set sourceFolder to (choose folder with prompt "Scegli la cartella sorgente:")

set targetFolder to (choose folder with prompt "Scegli la cartella da sincronizzare:")

display dialog "Stai per sincronizzare le due cartelle selezionate, l'operazione è irreversibile. Sei sicuro?" buttons {"Annulla", "Continua"} default button 1

if button returned of result is "Continua" then

do shell script "rsync -vaE --delete " & quoted form of POSIX path of sourceFolder & " " & quoted form of POSIX path of targetFolder

else

error "Operazione annullata dall'utente" number -128

end if


(109307)

Applescript "do shell script" variables

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