【问题标题】:Mac Automator - "Move finder items" using variableMac Automator - 使用变量“移动查找器项目”
【发布时间】:2019-06-23 05:46:44
【问题描述】:

我对 mac automator(在 Mojave 上)有一个奇怪的问题。

  • 我想要什么: 制作一个 pdf > 将每个页面保存为 png 到与 pdf 相同的文件夹中
  • 会发生什么: 获取 pdf > 所有 png 都保存到桌面

这是测试运行后的自动机:

您可以在屏幕截图中看到变量“pdfPath”实际上是如何正确设置为测试文件夹的。但是在移动后它确实将文件从系统文件夹中删除,但不是到 pdfPath 而是到桌面。重要提示:如果我手动选择任何文件夹,它将保存在那里而不是桌面,所以仍然与 pdfPath 变量相关?

有人知道为什么会发生这种情况以及如何解决吗?

【问题讨论】:

    标签: macos applescript automator


    【解决方案1】:

    Automator 有时会像这样令人沮丧。 Move Finder Items 操作在这种情况下似乎不适用于变量,即使您可以拖动并选择它们 - 当使用变量时,它默认为桌面。作为一种解决方法,您可以将 Move Finder Items 操作替换为 Get Value of Variable for pdfPath 以将其添加到输入项,然后添加 Run AppleScript 动作来做移动:

    on run {input, parameters}
      if (count input) < 2 then error "No Items to move.“
      set destination to last item of input
      tell application "Finder" to move (items 1 thru -2 of input) to destination
    end run
    

    您可能还必须从临时文件夹中清除以前的结果以保持重命名操作的顺利进行。

    【讨论】:

      【解决方案2】:

      好的,在此期间我在一些帮助下想通了。对于遇到并寻找解决方案的任何人,我在 Applescript 部分中保存的路径在结果中显示得很好,但最后,路径格式错误。下面的代码就像一个魅力:

      on run {input, parameters}
          tell application "Finder" to return POSIX path of (container of (item 1 of input) as alias) as text
      end run
      

      【讨论】:

      • 您也可以使用(container of item 1 of input) as alias,但您不必转换 Finder 项目,尤其是对于 Finder 操作。
      猜你喜欢
      • 2016-12-19
      • 2013-04-20
      • 2015-05-08
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 2013-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多