Applescript,显示所有带有标签的文件 [英] Applescript, show all files with tag

查看:33
本文介绍了Applescript,显示所有带有标签的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个 Applescript,它将根据当前时间打开显示所有标记为我当前所在学校课程的文件.例如,如果时间是星期二的上午 10 点,它将显示我所有标记为化学的文件.现在,我已经制作了 AppleScript 来获取类的正确名称.

I am trying to build an applescript which will open show all files tagged with the school class I am currently in, based on current time. For instance, if the time is 10 AM on a Tuesday, it will show all my files tagged with Chemistry. Now, I have made the AppleScript to get the correct name of the class.

现在我需要告诉 Finder 打开带有正确标签的文件.我该怎么做?

Now I need to tell Finder to open the files with the correct tags. How would I do this?

基本上是这样的:

set tagged to "Tag:Chemistry"
tell application "Finder"
    reveal tagged
    activate
end tell

当然,这里的标签是动态分配的.

Ofcourse, tagged here would be dynamically assigned.

推荐答案

您可以使用 GUI 脚本 在 finder 窗口中单击左窗格.

You can use the GUI Scripting to click on left-pane in the finder window.

因为此脚本使用 GUI Scripting 来控制用户界面,所以您必须将该小程序添加到一个批准列表中,该列表显示在安全 &隐私系统偏好设置面板.

Because this script use GUI Scripting to control the user-interface, you must add the applet to an approval list, displayed in the Security & Privacy system preference pane.

set tagName to "Chemistry" -- the full tag's name
my showFinderWindow(tagName)

on showFinderWindow(thisTag)
    tell application "Finder" to if not (exists Finder window 1) then make new Finder window
    tell application "System Events"
        tell process "Finder"
            repeat with i in windows
                tell outline 1 of scroll area 1 of splitter group 1 of i to if exists then
                    tell (first row whose value of its static text 1 is thisTag) to if exists then perform action "AXOpen" of static text 1
                    exit repeat
                end if
            end repeat
        end tell
    end tell
end showFinderWindow

这篇关于Applescript,显示所有带有标签的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆