How to create a toggle with Automator

Greetings,

I am attempting to create a runnable if/then script with Automator or Apple Scripts. I have minimal experience with Apple Scripts, so I do not know if this is even possible. I need the script to check if a particular folder has any content, and depending on the result, run one of two Automator scripts I have created.

If possible, I would love to have a toggle instead, simply switching off between my two Automator scripts.

Any help is much appreciated.

MacBook Pro with Retina display, OS X El Capitan (10.11.5), null

Posted on Jun 11, 2016 12:01 PM

Reply
2 replies

Jun 11, 2016 1:21 PM in response to Siriusic

Here is the basic flow to test if a specified folder is empty or otherwise. It calls automator once with the appropriate workflow.


property folder_to_check : ((path to desktop) as text) & "Test:" as alias

property workflow_for_items : ((path to home folder) as text) & "folder_has_items.workflow"

property workflow_for_noitems : ((path to home folder) as text) & "folder_has_noitems.workflow"


set qtdworkflow to ""


tell application "Finder"

if items of folder_to_check is {} then

set qtdworkflow to workflow_for_noitems'sPOSIX path'squoted form

else

set qtdworkflow to workflow_for_items'sPOSIX path'squoted form

end if

end tell


set theResult to do shell script "automator " & qtdworkflow


return

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 create a toggle with Automator

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