我正在尝试创建一个服务,将位于Finder的上下文菜单中,允许在当前目录中创建新文档。
我正在使用Automator进行操作:
不好意思,所有内容都是法语^^
无论如何,这里是我用来检索当前工作目录的AppleScript:
on run {input, parameters}
tell application "Finder"
set pwdAlias to insertion location as alias
if not (exists folder pwdAlias) then
set pwdAlias to (container of pwdAlias) as alias
end if
end tell
set pwd to POSIX path of pwdAlias
return pwd
end run
首先,我将该值设置为变量,然后使用变量作为文档路径创建一个新的文本文档,最后使用“在Finder中显示”命令显示已创建的文档。
除了脚本似乎总是延迟之外,一切都运行正常!我的意思是,当我打开一个新的Finder窗口并选择我的服务时,它总是在前一个窗口上创建文档,如下所示:
但是如果我再试一次,那么文档就会被正确地创建到预期位置:
而且这非常系统化,每次都会发生!!
抱歉,如果我表达得不太清晰,这不是很容易解释!
另外,我正在运行Mountain Lion,并附有Automator项目: create_new_document
要添加服务,请解压缩并将文件放在~/Library/Services/下
希望得到一些答案,但我担心这只是一个Automator的bug!