在OSX 10.6中,我使用以下代码对Finder中当前选择的每个文件执行某些操作:
app('Finder').selection.get.each do |item|
url =CGI::unescape(item.URL.get)
puts url
do_pdf(url[16..-1])
end(由Keyboard Maestro启动)。这工作得很好,然而在OSX Lion中,这种行为似乎发生了变化。
查找器仍然返回正确的参考应用程序(‘app"/System/Library/CoreServices/Finder.app"disks"Home"folders"stian"folders"Downloads"document_files"Comprehensive’).selection.get =>查找器检查(1).doc“
然而,当我尝试用URL.get提取它时,我得到了一个奇怪的数字:app('Finder').selection.get[0].URL.get => "file:///.file/id=6637683.2924283"
如何获取上述引用并将POSIX路径作为文本字符串(/Home/stian/Downloads/Comprehensive (1).doc)?
我可以获得整个参考的文本版本,如下所示:app('Finder').selection.get[0].get.to_s => "app("/System/Library/CoreServices/Finder.app").disks["Home"].folders["stian"].folders["Downloads"].document_files["Comprehensive Examination (1).doc"]"
因此,我想我可以手动解析它并构造POSIX路径,但这似乎非常麻烦和脆弱。
谢谢你的帮助!
发布于 2011-08-09 02:35:01
app('Finder').selection.get(resulttype=k.alias)[0].path我猜在Ruby中应该是
app('Finder').selection.get(:result_type=>:alias)[0].pathhttps://stackoverflow.com/questions/6976898
复制相似问题