【发布时间】:2015-05-04 11:48:55
【问题描述】:
我尝试拼凑一个 Keyboard Maestro 快捷方式,为我提供文件的 URL(就像路径查找器输出的那些)。
到目前为止,我使用以下 AppleScript 并将 空格 替换为 %20:
tell application "Finder"
set sel to the selection as text
set the clipboard to POSIX path of sel
end tell
然后我只需附加file://localhost/。
问题在于特殊字符,例如我的桌面上有以下文件夹:
我的输出:file://localhost//Users/patte/Desktop/#%20Old%20files
正确的输出应该转换散列:file://localhost/Users/patte/Desktop/%23%20Old%20files
AppleScript 或 Shell 脚本的解决方案会很棒,因为我能够将其合并。我也尝试过set the clipboard to URL of the first item of (get the selection),但这对我不起作用——也许我做错了。
另一种选择是对特殊字符进行编码的脚本 - 我也可以使用它,但我不确定要转换成什么 - 否则我会寻找它。
【问题讨论】:
标签: macos shell url applescript finder