【问题标题】:Automator Variable in shell scriptshell脚本中的Automator变量
【发布时间】:2011-06-07 12:45:16
【问题描述】:

是否可以将 Automator 变量传递到 shell 脚本中?

【问题讨论】:

    标签: macos shell unix automator


    【解决方案1】:
    1. 拖放
    2. filename变量中存储路径
    3. 下一个变量中输入值的提示窗口
    4. 获取 filename 变量
    5. 将提示值存储在rename_to
    6. $1 – rename_to 价值,$2 – filename 价值

    【讨论】:

      【解决方案2】:

      补充@Ned Deily's answer

      (从 OS X 10.9.2 开始编写,从 OSX 10.10 开始仍然有效)

      通常不需要在 Automator 中创建和使用显式变量(使用Set Value of VariableGet Value of Variable 操作)。

      上一个动作的输出会自动传递给Run Shell Script 动作。

      然而,默认情况下,数据是通过stdin传递的。

      如果您希望它作为 参数$1$2、... - 也可以通过 $@ 作为数组访问),请从 @987654331 中选择 as arguments右侧的@列表,如下图所示:

      在此示例中,选定的 Finder 项作为 POSIX 样式路径传递给 shell 脚本。


      也就是说,让 shell 脚本通过 stdin 处理数据(在循环中使用 read -r)也可以:

      【讨论】:

        猜你喜欢
        • 2022-06-11
        • 1970-01-01
        • 1970-01-01
        • 2023-03-18
        • 1970-01-01
        • 2014-09-29
        • 1970-01-01
        • 2014-05-08
        • 2016-02-29
        相关资源
        最近更新 更多