macos 从文件夹操作访问 Automator 中的文件名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1451486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Access file name in Automator from Folder Action
提问by davidavr
I'm trying to create a simple Automator workflow that will prompt me for where to move and rename a PDF when I download one from the web. I want to use this for downloading my monthly financial statements.
我正在尝试创建一个简单的 Automator 工作流程,当我从网上下载一个 PDF 时,它会提示我移动和重命名 PDF 的位置。我想用它来下载我的月度财务报表。
I'm getting stuck at what I thought would be a simple problem: passing the name of the new file(s) from the Folder Action into the Automator workflow.
我陷入了我认为是一个简单的问题:将新文件的名称从文件夹操作传递到 Automator 工作流程。
How is this done? I tried the "Get Specified Finder Items" action, disabling its input, and passed that to "Set Value of Variable" and in turn to "Ask for Conformation" so I could display the name of the file. It seems whatever I try, I cannot find how to pass the name of the newly downloaded files to the Automator workflow.
这是怎么做的?我尝试了“Get Specified Finder Items”操作,禁用其输入,并将其传递给“Set Value of Variable”,然后传递给“Ask for Conformation”,这样我就可以显示文件的名称。似乎无论我尝试什么,我都找不到如何将新下载的文件的名称传递给 Automator 工作流程。
This seems like it should be simple. Does someone have an example of an Automator workflow triggered by a Folder Action that passes the files into the workflow?
这看起来应该很简单。有人有一个由将文件传递到工作流的文件夹操作触发的 Automator 工作流示例吗?
采纳答案by Hai Vu
For the life of me, I can never understand Automator. However I believe I can help in this case. The action you are looking for is called "Get Selected Finder Items" -- it is not intuitive, blame Apple for that.
对于我的生活,我永远无法理解 Automator。但是,我相信在这种情况下我可以提供帮助。您正在寻找的操作称为“获取选定的 Finder 项目”——它不直观,因此请责怪 Apple。
To test out, I created a folder called "automator_action", then I started Automator (in Snow Leopard) and chose "Folder Action". This is the step you will need to figure out if you are using Leopard or earlier OS.
为了进行测试,我创建了一个名为“automator_action”的文件夹,然后我启动了 Automator(在 Snow Leopard 中)并选择了“文件夹操作”。这是您需要确定是否使用 Leopard 或更早版本的操作系统的步骤。
Next, I drag the "Get Selected Finder Items" (under Finder) over to the right pane, then I dragged the "Rename Finder Items" over and customized it. Finally, I saved the action and ready to test it out. You can see the picture presentation of my "script" here: http://farm3.static.flickr.com/2590/3937364947_33b1a3ab45_o.png
接下来,我将“获取选定的 Finder 项目”(在 Finder 下)拖到右侧窗格中,然后将“重命名 Finder 项目”拖到上方并对其进行自定义。最后,我保存了该操作并准备对其进行测试。你可以在这里看到我的“脚本”的图片展示:http: //farm3.static.flickr.com/2590/3937364947_33b1a3ab45_o.png
I tested out the action by dragging a file into this folder and sure enough, the action renames it the way I intended. Dragging multiple files also works. Good luck.
我通过将文件拖到此文件夹中来测试该操作,果然,该操作按我预期的方式对其进行了重命名。拖动多个文件也有效。祝你好运。