Automator/Applescript:如何从文件夹别名获取原始文件

Automator/Applescript:如何从文件夹别名获取原始文件,applescript,automator,Applescript,Automator,我正在尝试创建上下文菜单快捷方式,以便从原始项或其别名在VS代码中打开文件/文件夹 到目前为止,我能够创建一个Automator服务,该服务: 接收选定的文件或文件夹 在:任何应用程序运行 shell脚本: open-n-b“com.microsoft.VSCode”--args“$*” 如何将其更改为同时接受别名?符号链接应该可以,但查找器别名通常不起作用,因为大多数shell实用程序将其视为小数据文件,并且不知道如何解释它们。一种解决方案是添加一个运行AppleScript操作来查找输入

我正在尝试创建上下文菜单快捷方式,以便从原始项或其别名在VS代码中打开文件/文件夹

到目前为止,我能够创建一个Automator服务,该服务:

  • 接收选定的文件或文件夹
  • 在:任何应用程序运行
  • shell脚本:
open-n-b“com.microsoft.VSCode”--args“$*”


如何将其更改为同时接受别名?

符号链接应该可以,但查找器别名通常不起作用,因为大多数shell实用程序将其视为小数据文件,并且不知道如何解释它们。一种解决方案是添加一个运行AppleScript操作来查找输入中的别名,并使用原始项,例如:

  • 服务接收任何应用程序中的选定文件或文件夹
  • 运行AppleScript

    on run {input, parameters}
      set output to {} -- this will be a list of the output items
      tell application "Finder" to repeat with anItem in the input
        if anItem's kind is "Alias" then
          set the end of output to POSIX path of (original item of anItem as alias)
        else
          set the end of output to POSIX path of anItem
        end if
      end repeat
      return output
    end run
    
  • 运行Shell脚本

符号链接应该可以,但查找器别名通常不起作用,因为大多数shell实用程序将它们视为小数据文件,不知道如何解释它们。一种解决方案是添加一个运行AppleScript操作来查找输入中的别名,并使用原始项,例如:

  • 服务接收任何应用程序中的选定文件或文件夹
  • 运行AppleScript

    on run {input, parameters}
      set output to {} -- this will be a list of the output items
      tell application "Finder" to repeat with anItem in the input
        if anItem's kind is "Alias" then
          set the end of output to POSIX path of (original item of anItem as alias)
        else
          set the end of output to POSIX path of anItem
        end if
      end repeat
      return output
    end run
    
  • 运行Shell脚本