[英]Automator Quick Action to Save Images into Same Folder
I'm trying to make an Automator Quick action (Mac OS) that will save images from pdf pages into the same folder where the pdf is located .我正在尝试制作一个 Automator Quick action (Mac OS),它将 pdf 页面中的图像保存到 pdf所在的同一文件夹中。
**Edit: user3439894 wrote that I should have and did not make totally clear that I want "to send multiple files to the Quick Action from different folders and have the files created in each respective folder the file is in" **编辑:user3439894 写道,我应该并且没有完全清楚我想“将多个文件从不同文件夹发送到快速操作,并在文件所在的每个文件夹中创建文件”
I found that it's easy to have files saved to a particular folder;我发现将文件保存到特定文件夹很容易; for example, here's a workflow that saves images from a pdf to the desktop:
例如,这是将图像从 pdf 保存到桌面的工作流程:
The hard part is saving to the same folder where the pdf is located.困难的部分是保存到 pdf 所在的同一文件夹中。 I tried to adapt this answer , but I get: "Rename Finder Items: Name Single Item" encountered an error: "More than one Finder item was passed to Name Single Item".
我试图修改这个答案,但我得到:“重命名 Finder 项目:命名单个项目”遇到错误:“多个 Finder 项目被传递给命名单个项目”。 I don't know how to fix that -- the whole point of my task is to output multiple images from the .pdf.
我不知道如何解决这个问题——我的任务的重点是从 .pdf 输出多个图像。
There are actually 2 workflows shown on the stackoverflow page I mentioned above . 我上面提到的 stackoverflow 页面上实际上显示了2 个工作流。 I tried adapting both of them and they both gave the same error.
我尝试对它们进行调整,但它们都给出了相同的错误。 Below is one of my adaptions.
以下是我的改编之一。 The "Get Specified Finder Items" action is just for testing purposes.
“获取指定的 Finder 项目”操作仅用于测试目的。
This gets a bit convoluted because Automator doesn't have a default action to get names or paths (that was one of my first actions back in the day), you need to shuffle stuff around while you work at getting items into variables, and workflows handle multiple input items as a single batch.这有点令人费解,因为 Automator 没有用于获取名称或路径的默认操作(这是我当天的第一个操作之一),您需要在将项目放入变量和工作流中的同时进行调整将多个输入项目作为一个批次处理。
The Rename Finder Items action will only rename (you need to use the Make Sequential option rather than Name Single Item ), but that doesn't help much, especially since the Render PDF Pages as Images action also uses sequential numbers in its output. Rename Finder Items操作只会重命名(您需要使用Make Sequential选项而不是Name Single Item ),但这并没有多大帮助,特别是因为将PDF 页面渲染为图像操作也在其输出中使用序列号。
For items with the same parent folder (otherwise a third party action would need to be used to handle the items individually), a Run AppleScript action can be used (as in your linked examples) to get the parent folder for use in a variable, so your workflow would be something like:对于具有相同父文件夹的项目(否则需要使用第三方操作来单独处理这些项目),可以使用Run AppleScript操作(如您链接的示例中所示)来获取父文件夹以用于变量,所以你的工作流程是这样的:
Run AppleScript:运行 AppleScript:
on run {input, parameters} tell application "Finder" to return (container of first item of input) as alias end run
I found a way that works for me.我找到了一种适合我的方法。
Run AppleScript:运行 AppleScript:
on run {InputPDFs, parameters} tell application "Finder" to return (container of first item of InputPDFs) as alias end run
Set Value of Variable {Variable: PathToPDFs}设置变量 {Variable: PathToPDFs} 的值
The following solution in the screenshot works fine in Catalina (10.15.7).屏幕截图中的以下解决方案在 Catalina (10.15.7) 中运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.