0

I am trying to show a list of specific files in the Finder via applescript, in a similar way as what you get when you search for files. This is what I got working

tell application "Finder" to reveal list_of_files

but this only reveals the last file on the list - not all of them.

I am aware of this answer, but I'd need this to work with applescript.

Community
  • 1
  • 1
simone
  • 4,667
  • 4
  • 25
  • 47
  • You can try a spotlight search as discussed here: (link: http://macscripter.net/viewtopic.php?id=27833), but I don't think there's an easy way to show a search finder window. – Nick Groeneveld Jul 03 '15 at 07:50
  • Thanks! However I _have_ a list of files. My problem is - given the file list - how to display *only* those files in the finder. – simone Jul 03 '15 at 08:31
  • 1
    If the files are in the same folder you can choose to show the folder instead of the files. If they are not in the same folder you could move them all to a temp folder and then show that folder. – Nick Groeneveld Jul 03 '15 at 08:53
  • I +1'd NGAFD and to take it a step further, use an alias/file link to reduce entire file duplication. – Frank C. Jul 03 '15 at 13:11

2 Answers2

0

The function Reveal shows the list of file pre-selected, only if the files are in the same folder. in single folder, your list should be made of the complete path of each file : Tell application "Finder" Set my_folder to "HD:Users:my_account:Desktop:test_folder: Set My_List to {(my_folder & "A.doc"), (my_folder & "C.doc"),(my_folder & "E.doc")} Reveal My_List end tell

if your file are in different folders, Reveal will just display the last files from the last folder

pbell
  • 2,965
  • 1
  • 16
  • 13
0

To continue on my comment yesterday, you can move the files to a temp folder of your choosing. It is not possible to display files from different locations in one finder window, so this is the best workaround I could think of.

In this example it will display two dialogs for you.

  1. To choose the folder containing the files. You can change this to your list
  2. To choose the destination folder. You can change this to your preferred location, too.

    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
    
Nick Groeneveld
  • 895
  • 6
  • 18