我正在尝试实现一项功能,即在OSX Finder中右键单击视频文件,按下“服务”和我的脚本名称,然后MediaInfo会在终端中加载并显示视频标签数据。我已经成功实现了对本地驱动器中文件的操作。但是对于网络驱动器,由于路径中缺少/Volumes,因此MediaInfo找不到该文件。
我已将以下脚本放置在Automator的“运行AppleScript”中,并保存为服务(Automator顶部的“服务接收Finder中选择的文件或文件夹”):
我已将以下脚本放置在Automator的“运行AppleScript”中,并保存为服务(Automator顶部的“服务接收Finder中选择的文件或文件夹”):
tell application "Finder"
set theItems to selection
repeat with itemRef in theItems
set myfolder to (get folder of itemRef) as string
set myfolder to POSIX path of myfolder
set myfile to "'" & myfolder & (get name of itemRef) & "'"
end repeat -- it will store the last filename in selection
end tell
tell application "Terminal"
activate
do script
set size of window 1 to {1200, 1200}
set cmd to "mediainfo " & myfile
try
if busy of selected tab of window 1 then error
do script with command cmd in window 1
on error
do script with command cmd
end try
end tell
那么,如果涉及网络驱动器,要如何更改路径以在开头包含 /Volumes 呢?