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

Applescript to skip Automator step

I'm trying to create a workflow to sync two folder with some option, such as "Sync even the icon" or "Sync remote folders".

What I need to do is put an Applescript on the top of the workflow to ask these options and then if, for example, the option "Sync the icon" is enabled, the applescript must run only determined actions that I specify.


My current Automator workflow:

- Ask for finder items

- Set value of variable 1

- Ask for finder items

- Set value of variable 2

- Ask for confirmation

- Get value of variable 1

- Get value of variable 2

- Run script shell


What I want to do:

- Run Applescript to ask options and then depending on the option chosen run determined actions

- Ask for finder items

- Set value of variable 1

- Ask for finder items

- Set value of variable 2

- Ask for confirmation

- Get value of variable 1

- Get value of variable 2

- Run script shell - this if the options chosen are "Sync the icon" and "Sync local folders"

- Run script shell - this if the options chosen are "Don't sync the icon" and "Sync local folders"

- Run script shell - this if the options chosen are "Sync the icon" and "Sync remote folders"

- Run script shell - this if the options chosen are "Don't sync the icon" and "Sync remote folder"


If isn't possible to do this, is it possible to convert actions to applescript?

Posted on Jul 8, 2014 5:28 AM

Reply
Question marked as Best reply

Posted on Jul 8, 2014 7:46 AM

I don't understand what 'sync the icon' means but that may be irrelevant?


Personally I'd start by keeping it simple – split it into 2 (or even 4) workflows…

  • Sync local folders (icons)
  • Sync local folders (no icons)
  • Sync remote folders (icons)
  • Sync remote folder (no icons)

The remote & local version could be a single workflow with a choice of 'icon' or 'no icons'.

That way you can keep the logic to a minimum inside Automator or Applescript.


If it must all be inside one Application/workflow you could try something inside a "Run Applescript" action…

on run {input, parameters}


setchoicetochoose from list {"Sync local folders (icons)", "Sync local folders (no icons)", "Sync remote folders (icons)", "Sync remote folder (no icons)"}

return choice

end run


Then you need to decide if an Applescript action or a shell script action is handling all the logic…

For example a "Run shell script" action will speak the you the result of the Applescript choice via…


say "$@"



It gets complex as you start handling all the variables. I'm unsure if you would be better with an Applescript or even a shell script - it really depends on what your overall aim is and how the sync is being performed. Are you making this for others to use?


P.S. You may want to explain what exactly you are syncing - it may be easier (and more logical to manage) by using an Application like Chronosync which can save 'sync jobs'.

4 replies
Question marked as Best reply

Jul 8, 2014 7:46 AM in response to Matteo_999

I don't understand what 'sync the icon' means but that may be irrelevant?


Personally I'd start by keeping it simple – split it into 2 (or even 4) workflows…

  • Sync local folders (icons)
  • Sync local folders (no icons)
  • Sync remote folders (icons)
  • Sync remote folder (no icons)

The remote & local version could be a single workflow with a choice of 'icon' or 'no icons'.

That way you can keep the logic to a minimum inside Automator or Applescript.


If it must all be inside one Application/workflow you could try something inside a "Run Applescript" action…

on run {input, parameters}


setchoicetochoose from list {"Sync local folders (icons)", "Sync local folders (no icons)", "Sync remote folders (icons)", "Sync remote folder (no icons)"}

return choice

end run


Then you need to decide if an Applescript action or a shell script action is handling all the logic…

For example a "Run shell script" action will speak the you the result of the Applescript choice via…


say "$@"



It gets complex as you start handling all the variables. I'm unsure if you would be better with an Applescript or even a shell script - it really depends on what your overall aim is and how the sync is being performed. Are you making this for others to use?


P.S. You may want to explain what exactly you are syncing - it may be easier (and more logical to manage) by using an Application like Chronosync which can save 'sync jobs'.

Jul 8, 2014 9:49 AM in response to Drew Reece

Thanks, you helped me, but not at all.


In a few words, i'm trying to create a single workflow to sync two folders, but since to sync folders with icon (of the folder), or sync remote folders i have to write different command line in rsync, I want to ask at the application start if the folders are local or remote and if is wanted to sync even the icon. With these information make the application run different action.

If folders are local with icon:

- Ask for finder items

- Set value of variable 1

- Ask for finder items

- Set value of variable 2

- Ask for confirmation

- Get value of variable 1

- Get value of variable 2

- Run script shell (rsync -vaE (this -E is to sync even the icon) "$1/" "$2/")


If folders are local without icon:

- Ask for finder items

- Set value of variable 1

- Ask for finder items

- Set value of variable 2

- Ask for confirmation

- Get value of variable 1

- Get value of variable 2

- Run script shell (rsync -va --exclude=Icon "$1/" "$2/")


If folders are remote with icon:

- Applescript to ask the path and ip of the remote computer and set value of variable 1

- Ask for finder items

- Set value of variable 2

- Ask for confirmation

- Get value of variable 2

- Get value of variable 1

- Run script shell (rsync -vaE "$2/" "$1/")


If folders are remote without icon:

- Applescript to ask the path and ip of the remote computer and set value of variable 1

- Ask for finder items

- Set value of variable 2

- Ask for confirmation

- Get value of variable 2

- Get value of variable 1

- Run script shell (rsync -va --exclude=Icon "$2/" "$1/")

What I can't do is put all these actions inside a single application. I'm making this app for other, and I really want to do this with a workflow and not download it already done.



Applescript to skip Automator step

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