How do I get these results in separate automator variables?

柔情痞子 提交于 2021-02-07 08:29:20

问题


I have made a small automator script that runs a bash shell script and gets two outputs... On viewing results it appears like this below...

Multiple Results

I want them in two automator variables Assume I used a script like

echo "200"
echo "19 hours, 4 minutes and 42.765 seconds"

and on viewing the results it shows this (and I want each of these as automator variables called count and duration). I want it to be sent to a display notification with subtitle as "count files processed" and message as "duration elapsed". How can I achieve this?


回答1:


You can modify Automator variables by applescript. The variables must exists in the workflow, so you first should add two variables, to get something like on the next image:

enter image description here

You can set anyting as their initial value...

After the above, you can use the next applescript, right after your shell script

on run {input, parameters}
    set value of variable "Count" of front workflow to item 1 of input
    set value of variable "Duration" of front workflow to item 2 of input
    return input
end run

It is not fully correct, (for example it isn't check the number of arguments on the input), but you get an idea.

So after the next:

enter image description here

Your automator variable Count will contain 200, and the variable Duration will contain the text.



来源:https://stackoverflow.com/questions/25576397/how-do-i-get-these-results-in-separate-automator-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!