自动将特定文件夹中的新文件复制到剪贴板

自动将特定文件夹中的新文件复制到剪贴板

我正在使用 macOS 应用来创建 GIF(名为吉夫福克斯),但应用程序不提供自动保存到剪贴板的功能。但是,我可以定义 GIF 的保存位置。如何创建自动化:

  1. 监听此文件夹中的新文件并将其自动复制到剪贴板(首选 UX)
  2. 执行某个快捷方式后,将文件夹中的最新文件复制到剪贴板(不太理想)。

我知道我可以通过 Automator 触发脚本。我正在寻找可以实现这一点的脚本。

答案1

您可以保存以下内容苹果脚本编码脚本编辑器.app作为“File_To_Clipboard.scpt”(或任何你想要的名字)到你的/Users/你的简称/Library/Scripts/Folder Action Scripts/ 文件夹(如果该目录尚不存在,则需要创建该目录)。

property theFile : missing value

on adding folder items to theFolder after receiving theNewItems
    --  Called after items have been added to a folder
    
    --  theFolder is a reference to the modified folder
    --  theNewItems is a list of references to the items added to the folder 
    
    set theFile to POSIX path of theNewItems
    set the clipboard to POSIX file theFile
    
end adding folder items to

然后在发现者,右键单击将保存 GIF 文件的文件夹,然后选择文件夹操作设置...然后选择新的“File_To_Clipboard.scpt”文件附加到该文件夹​​。

现在,只要将文件添加到该文件夹​​,该文件就会被复制到剪贴板。(原始答案来自wch1zpink 这里

相关内容