废话不多说,上核心AppleScript代码:
on alfred_script(q)
tell application "Finder"
--set theItems to selection
--set filePath to (POSIX path of (the selection as alias))
set folderPath to POSIX path of (target of window 1 as alias)
end tell
set q to folderPath
return q
end alfred_script
其中被注释的部分是Finder中被选中文件的路径.
最终达到的效果:当前焦点应用为Finder时,敲Option+Space调出Alfred输入框,输入cfp,回车,即可把Finder中的当前文件夹路径复制到剪贴板。