【问题标题】:Use Automator to read a text file and copy contents to another Folder使用 Automator 读取文本文件并将内容复制到另一个文件夹
【发布时间】:2019-05-22 23:51:36
【问题描述】:

我有一个文本文件,其中包含大约 500 张图片的文件名。

我想使用 Automator 来:

  1. 读取文本文件

  2. 获取名称列表

  3. 查看包含大约 1000 张图片的“存储库文件夹”

  4. 将对应图片复制到新文件夹中。

Mac 上的 Automator 可以做到这一点吗?

这是我尝试过的,但它不起作用。

【问题讨论】:

  • Automator 专为不需要决策的重复性任务而设计。但是,您可以添加一个 Run AppleScript 动作来解决问题。如果您可以发布有关“存储库文件夹”的一些详细信息,我们可以帮助您制作 AppleScript 来解决这个问题。
  • 感谢您的提示。 repo 文件夹只是我桌面上的一个文件夹。它仅包含 1000 多张图片。没有子文件夹。
  • 目标文件夹呢?
  • 只是桌面上的另一个文件夹。

标签: text automation applescript automator


【解决方案1】:

以下是 Automator 操作,按顺序排列:

Run AppleScript Action 中的这段代码应该可以解决问题:

on run {input, parameters}

    set imgDestination to input's item 2
    set imgSource to input's item 1

    set imgNameFile to choose file with prompt {"Select file of image filenames:"}

    set imageList to every paragraph of (read imgNameFile)

    repeat with eachName in imageList
        tell application "Finder"
            set targetImageFile to item 1 of (get every file in folder imgSource whose name = (eachName as text))
            duplicate targetImageFile to folder imgDestination
        end tell
    end repeat
    return input
end run

我无法设计如何让 Automator 读取文本文件,并在选择文件夹时记住它,所以我添加了选择带有图像文件名的文件作为 AppleScript 的一部分。

祝你好运,

【讨论】:

  • 哇!非常感谢!这真的很有帮助!
猜你喜欢
  • 2019-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-05
  • 2016-03-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多