获得一个PDF打印对话框中的Automator OSX的文件名 [英] Getting the Filename of a pdf print dialog in osx automator
问题描述
我创建一个Automator的PDF打印插件。
I'm creating an automator pdf print plugin.
当您选择打印插件的文件名到PDF的输入(通常在/ var /东西/documentName.pdf)
When you choose the print plugin the filename to the pdf is the input (normally /var/something /documentName.pdf)
我想获得documentName要在重命名Finder项用到它。
I would like to get the documentName to use it later in an Rename Finder Item.
我使用ATM的AppleScript做到这一点。
I'm using atm applescript to accomplish this.
on run {input, parameters}
tell application "Finder"
set fileName to name of ((POSIX file input) as alias)
end tell
return fileName as string
end run
问题是,这只能当我把它显示了POSIX路径的AppleScript之前文本操作的问。
The problem is that this only works when I put an Ask for Text Action before the applescript which displays the posix path.
如果我删除请求文本行动AppleScript的失败。
If I remove the Ask for Text action the applescript fails.
工作流是 https://www.dropbox.com/ S / jp4t9pen3gvtyiq / Rename-Action.workflow.zip
我想这是简单的东西,但是这是第一次的AppleScript / Automator的工作流程我创建。
I guess it is something simple but this is the first applescript / automator workflow I'm creating.
当我失败的评论
解决办法就是
on run {input, parameters}
tell application "Finder"
set fileName to ((name of first item of input) as string)
end tell
return fileName
end run
如下面@Ken职务。
as by @Ken post below.
谢谢!
推荐答案
我创建了一个测试流程与此AppleScript的:
I created a test workflow with this AppleScript:
on run {input, parameters}
tell app "System Events"
display dialog ((class of input) as string)
end
return input
end run
这显示的名单。然后我把它修改为:
That displayed "list". I then modified it to:
on run {input, parameters}
tell application "System Events"
display dialog ((class of first item of input) as string)
end tell
return input
end run
这显示的别名。
因此,输入到一个PDF工作流程是别名列表。编写与你的脚本一点,它应该工作。例如,这个作品:
So, the input to a PDF workflow is a list of aliases. Write your script with that in mind and it should work. For example, this works:
on run {input, parameters}
tell application "System Events"
display dialog ((name of first item of input) as string)
end tell
return input
end run
这篇关于获得一个PDF打印对话框中的Automator OSX的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!