如何在Applescript中回显值/变量?

时间:2018-04-17 22:18:14

标签: applescript

免责声明:我对此非常陌生。

我有一个使用count命令检索的数字,现在我想使用"将shell脚本回显输出到.txt文件。"

到目前为止我的代码:

tell application "Things3"
    set todayToDos to to dos of list "Today"
    count todayToDos
    do shell script "echo todayToDos > /Users/nonefirstnonelast/Desktop/Things.txt"
end tell

控制台输出为:

""
without do shell script "echo todayToDos > /Users/nonefirstnonelast/Desktop/Things.txt" line it is: 27

1 个答案:

答案 0 :(得分:0)

您必须将count行的结果分配给变量。然后,您必须将整数强制转换为文本,并在shell脚本行中插入变量的值。

tell application "Things3"
    set todayToDos to to dos of list "Today"
    set numberOfTodos to count todayToDos
end tell
do shell script "echo " & (numberOfTodos as text) & " > /Users/nonefirstnonelast/Desktop/Things.txt"