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!
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
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.
In the Variables Library, under Utilities, drag an
AppleScript variable into the Workflow above the Choose from List action.
Edit the Variable Options and define its Script as an array of text strings, containing your desired list of choices.
You need to break up the text into a list of items, which is what Choose from List expects as input. You can use a Filter Paragraphs action to break up the text, for example return paragraphs that are not empty.
You don't mention what OS you are running, but Lion added the ability to use Rich Text in the text actions - unfortunately, most of the actions don't work as intended if they actually get Rich Text. In Lion, you can take advantage of some of the (hidden) input item coercions by using something like a Run Shell Script action (you don't need to put anything extra in there, just use the default, which passes items through) to convert Rich Text from the Get Specified Text action.
The Choose from List action has the All or None buttons, but there isn't a way to select a specified set of items. It is reasonably easy to write Automator actions, so rolling your own textutil wrapper would be another option.
There are also two Automator Actions that will also solve this problem.
One is Split Text which allow you to choose a certain delimiter to split the text.
The other is Get Words of Text which allows you to just get the individual words of text passed as input.
If you don't have these actions, you can get them from here:
https://itunes.apple.com/us/app/text-automator-actions-pack/id448838274?mt=12