Sorting var to "Prompt With List "" From Variable "tmp"

I have a script that looks in a folder at the files there, does some sed stuff and puts the files names, one per line into the KM variable tmp. When I inspect the variable the files are sorted correctly via the code.

ls -t | sed -e 's/.[^.]*$//

When I execute the script with the "Prompt With List "" From Variable "tmp" action I get the list in an alphabetical sort rather than the newest date sort that appears when inspection the variable in KM. There appears to be no sort option within the action.

New and impressed by all the smart coders here. Frankly a bit intimidated.

1 Like

Hey Will,

Most new things are at least a little bit intimidating. Don't let that stop you from asking questions and performing experiments though.  :wink:

I've asked @peternlewis a couple of times to make the Prompt With List action's sort optional, but he's never committed. If you want that feature then petition for it. The more users who do, the more likely it will come about.

This fabulous macro by @DanThomas has more options than the built in prompt from list.

MACRO: Spotlight Search Prompt

And of course there is the AppleScript method, which is much less powerful but much simpler.

set myList to "one
two
three
four
five
six
seven
eight
nine
ten"

set myList to paragraphs of myList

tell application (path to frontmost application as text)
   set myChoice to choose from list myList ¬
      with title ¬
      "MyTitle" with prompt ¬
      "MyPrompt" default items (item 1 of myList) ¬
      multiple selections allowed true ¬
      without empty selection allowed
end tell

-Chris

Just call me Mr. Fabulous. :stuck_out_tongue:

1 Like