macos - 如何添加将使用单个选定文件的 Finder 服务,在其上执行 shell 脚本,然后将其显示为对话框窗口?
问题描述
如何添加将使用单个选定文件的 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的新手,不知道如何让它工作。任何帮助表示赞赏。
解决方案
Automator 服务将输入项传递给工作流,因此您无需执行任何其他操作即可获得选择。在Run AppleScript操作中,input
参数是一个列表,因此您应该选择一个特定的项目或只是循环所有项目:
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
推荐阅读
- amazon-web-services - 解密 AWS 托管密钥
- c# - 如何使用 DI usinq autofac .net 框架注册 ILogger(Microsoft.Extensions.Logging)
- centos - 无法在 CentOS 上安装 Review board
- java - 为什么我得到空括号作为对 http GET 请求的响应
- mysql - 选择给定日期时间在另外两个之间的行不起作用
- r - R中cmdscale的意外结果
- three.js - EdgesGeometry 不显示任何内容?
- c - 如何检查文件权限中的“+”?(ACL)
- google-apps-script - 如何丢弃草稿并在谷歌应用脚本中实时更新
- cucumber - 黄瓜正则表达式步骤定义