Path AppleScript用于获取所选文件的POSIX路径,在网络驱动器上也是如此

Path AppleScript用于获取所选文件的POSIX路径,在网络驱动器上也是如此,path,terminal,applescript,posix,finder,Path,Terminal,Applescript,Posix,Finder,我正在尝试在OSX Finder中右键单击视频文件,按Services和脚本名称,然后MediaInfo将加载到终端,视频标签数据将显示(由MediaInfo显示)。我让它在我本地驱动器的文件中工作。但它不适用于网络驱动器,因为路径中缺少/Volumes,并且MediaInfo找不到该文件 我已将以下脚本作为RunAppleScript放入Automator,另存为服务(“服务在Automator顶部的Finder中接收选定的文件或文件夹”) 那么,当网络驱动器出现问题时,为了在路径的开头包

我正在尝试在OSX Finder中右键单击视频文件,按Services和脚本名称,然后MediaInfo将加载到终端,视频标签数据将显示(由MediaInfo显示)。我让它在我本地驱动器的文件中工作。但它不适用于网络驱动器,因为路径中缺少/Volumes,并且MediaInfo找不到该文件

我已将以下脚本作为RunAppleScript放入Automator,另存为服务(“服务在Automator顶部的Finder中接收选定的文件或文件夹”)


那么,当网络驱动器出现问题时,为了在路径的开头包含/Volumes,应该更改什么呢?

您可以获取查找程序项的Disk属性,然后可以检查磁盘的local volume属性是否设置为false

我没有试过,但我想你必须把这个项目作为一个项目来处理。(
将项目别名的磁盘设置为

这至少在理论上会让您更接近,我认为要让它发挥作用,我想您应该知道posix路径应该是什么样子,包括/Volumes/网络卷/到/file的路径等等

Finder还有一个属性startup disk,我认为您可以使用它来比较驱动器,如果这样对您更合适的话


所有内容都在AppleScript编辑器的Finder字典中。

一些东西,无法理解为什么要隔离文件名,然后重新添加它。使用项目名称有时包括扩展名,但有时不包括扩展名。网络驱动器尤其如此。 而且,不要把不需要的东西放在Finder块中。上半部分适用于选定的文件和文件夹,包括网络驱动器上的文件和文件夹,包括posix路径中的卷/文件

tell application "Finder" to set theItems to selection
repeat with itemRef in theItems
    set myitem to POSIX path of (itemRef as string)
end repeat -- it will store the last filename in selection

经过一些尝试和错误,这似乎是一个适合我的工作脚本(将此脚本作为上下文菜单项运行,以在新的终端窗口中显示MediaInfo输出):


谢谢,不过这只是给了我们一条路。所以,这似乎是可行的:告诉应用程序“Finder”将items设置为selection;在EMS中重复itemRef;将myitem设置为“'”&POSIX路径(itemRef作为字符串)和“'”;重复结束——但我的终端部分也有一个大问题。不管我怎么做,它总是打开两扇窗户或者做一些不想要的事情。如何始终为我的命令打开一个新的终端(不是double,也不是已经打开的终端)?当有多个参数带有空格时,“set myitem to”行由于引号而不起作用。单独使用“”而不是“”,似乎有效。
tell application "Finder" to set theItems to selection
repeat with itemRef in theItems
    set myitem to POSIX path of (itemRef as string)
end repeat -- it will store the last filename in selection
tell application "Finder" to set theItems to selection
repeat with itemRef in theItems
    set myitem to "'" & POSIX path of (itemRef as string) & "'"
end repeat -- it will store the last filename in selection

tell application "Terminal"
    launch
    activate
    do script
    set size of window 1 to {1200, 1200}
    do script "mediainfo " & myitem in window 1
end tell