我可以使用Applescript在Finder窗口中显示特定文件吗?

时间:2015-07-03 07:41:04

标签: applescript finder

我试图通过applescript显示Finder中的特定文件列表,其方式与搜索文件时的方式类似。这就是我的工作

tell application "Finder" to reveal list_of_files

但这只会显示列表中的最后一个文件 - 不是全部文件。

我知道this answer,但我需要这个才能使用applescript。

2 个答案:

答案 0 :(得分:0)

Reveal功能显示预先选择的文件列表,仅当文件位于同一文件夹中时。 在单个文件夹中,您的列表应由每个文件的完整路径组成:     告诉申请" Finder"     将my_folder设置为" HD:用户:my_account:桌面:test_folder:     将My_List设置为{(my_folder&" A.doc"),(my_folder&" C.doc"),(my_folder&" E.doc" )}     揭示My_List     结束告诉

如果您的文件位于不同的文件夹中,Reveal将只显示最后一个文件夹中的最后一个文件

答案 1 :(得分:0)

要继续我昨天的评论,您可以将文件移动到您选择的临时文件夹中。在一个查找程序窗口中无法显示来自不同位置的文件,因此这是我能想到的最佳解决方法。

在此示例中,它将为您显示两个对话框。

  1. 选择包含文件的文件夹。您可以将其更改为列表
  2. 选择目标文件夹。您也可以将其更改为您的首选位置。

    tell application "Finder"
    
        -- 1
        set myFiles to (every file in (choose folder))
        -- 2
        set destinationFolder to choose folder
    
        repeat with i from 1 to count of myFiles
            move item i of myFiles to destinationFolder
        end repeat
    
        reveal (item (count of myFiles)) of destinationFolder
    
    end tell