Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automator: How do I use the Choose from List action?

I'm trying to create a Service using Automator that simply calls textutil convert. Eventually, I want to be able to right-click a docx file and convert to text, rtf, html, etc. After I right-click I want a very simple popup asking for the desired format.

I see the Choose from List action. It has no options. Somewhere I got the idea to make the input of Choose from List be Get Specified Text. I then tried putting my list of values in Get Specified Text. However, when I run it, I only get one line. I've tried one item per line, comma-delimited, space-delimited and even surrounding with curly braces, delimited with commas. Nothing works.

How do I get that chooser dialog to show all my options? Also, is there a way to restrict the selection to one item?

Thanks!

automator screenshotresult

like image 334
bmauter Avatar asked Jul 11 '12 19:07

bmauter


People also ask

How do I get my Mac Automator to workflow automatically?

When you create the Automator workflow, choose "Application" instead of "Workflow." This creates a stand-alone app that will run with the double-click instead of opening Automator. Since you already have the Workflow, you can open it and then choose File, Convert To... Then choose Application.


2 Answers

The trick is to use an AppleScript variable!

The other suggested answers work, but the simplest and most straightforward way is to use an AppleScript variable to define the list choices.

A text variable can store only one item of plain text, but an AppleScript variable can be structured as an array, which is exactly what you need to define a list.

enter image description here

  1. In the Variables Library, under Utilities, drag an AppleScript variable into the Workflow above the Choose from List action.

  2. Edit the Variable Options and define its Script as an array of text strings, containing your desired list of choices.

like image 161
ElmerCat Avatar answered Oct 23 '22 11:10

ElmerCat


Here is the solution to select only one line in a list.

Remove ("Get Specified Text" and "Choose from List") actions.

Add the "Run AppleScript script" action. 1- Cut the text in the action. 2- Copy/paste this text in the action.

on run
    choose from list {"TXT", "RTF", "RTFD", "HTML"} with prompt "Please make your selection" without multiple selections allowed and empty selection allowed
    return the result as string
end run
like image 44
jackjr300 Avatar answered Oct 23 '22 12:10

jackjr300