Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何添加使用单个选定文件的Finder服务,在其上执行shell脚本,然后将其显示为对话框窗口?_Macos_Shell_Applescript_Automator_Finder - Fatal编程技术网

Macos 如何添加使用单个选定文件的Finder服务,在其上执行shell脚本,然后将其显示为对话框窗口?

Macos 如何添加使用单个选定文件的Finder服务,在其上执行shell脚本,然后将其显示为对话框窗口?,macos,shell,applescript,automator,finder,Macos,Shell,Applescript,Automator,Finder,如何添加使用单个选定文件的Finder服务,在其上执行shell脚本,然后将其显示为对话框窗口 我目前让Automator在Finder中接收文件和文件夹,然后运行包含以下内容的Applescript: on run {input, parameters} tell application "Finder" set filename to selection set filename to quoted form of POSIX file filena

如何添加使用单个选定文件的Finder服务,在其上执行shell脚本,然后将其显示为对话框窗口

我目前让Automator在Finder中接收文件和文件夹,然后运行包含以下内容的Applescript:

on run {input, parameters}
    tell application "Finder"

        set filename to selection
        set filename to quoted form of POSIX file filename
        set theCMD to "/usr/local/bin/exiftool "
        set theScript to theCMD & filename
        set theResult to do shell script theScript
        display dialog theResult
    end tell
end run
我不断收到错误。其目的是显示一个对话框窗口,其中包含Finder窗口中单个选定文件的Exif元数据信息。我使用brew安装exiftool来检索数据


我是applescript新手,不知道如何让它工作。感谢您的帮助。

自动程序服务将输入项传递到工作流,因此您无需执行任何其他操作即可获得选择。在运行AppleScript操作中,
输入
参数是一个列表,因此您应该选择一个特定的项目,或者只是循环所有项目:

on run {input, parameters}
    repeat with anItem in the input
        set anItem to quoted form of POSIX path of anItem
        set theResult to (do shell script "/usr/local/bin/exiftool " & anItem)
        display dialog theResult
    end repeat
    # return input
end run

令人惊叹的。一个附带的问题。。。就像在python中使用type命令一样,applescript中是否有一个等效的命令可以显示输入变量的类型?列表字符串?
input
参数将始终是工作流输入和以前操作中的项目列表。要获取列表中单个项目的类型(它们可以不同),可以获取其类属性,例如,anItem的
class