applescript to reveal multiple files in Finder

Discussion in 'Mac Programming' started by chrispoole, Feb 25, 2011.

  1. chrispoole macrumors newbie

    Joined:
    Sep 26, 2007
    #1
    Hi, I'm trying to get this to work:

    Code:
    tell application "Finder"
    	reveal {"/Users/Chris/test/test.pdf", "/Users/Chris/test/test.log"} as POSIX file
    end tell
    Basically, just reveal the files, several selected at once.

    It doesn't work though, and I've searched round to find a solution but can't get anything to work.

    Can anyone help please?
     
  2. andmr macrumors member

    Joined:
    Aug 25, 2008
    Location:
    NE Florida
    #2
    Since the two items in your example list reside within the same folder, all you'd really need to do is reveal the items' enclosing folder. Once this folder is revealed, the two files should be plainly visible. Try this:

    Code:
    tell application "Finder"
    	reveal folder ((path to home folder as text) & "test:")
    end tell
    
    If, however, you want to take it a step further and actually select (highlight) any folder items which appear on the list, you might try this:

    Code:
    set my_list to {"test.pdf", "test.log"}
    tell application "Finder"
    	set my_folder to reveal folder ((path to home folder as text) & "test:")
    	select (every item of my_folder whose name is in my_list)
    end tell
    To test that only listed items get highlighted, try adding non-list items to the test folder, and then rerun the script.

    Good luck.
     
  3. balasoundiram, Sep 18, 2014
    Last edited by a moderator: Sep 18, 2014

    balasoundiram macrumors newbie

    Joined:
    Sep 18, 2014
    #3
    I'm trying to select folders/files located within the parent folder. Any suggestion on how to do this.
    Code:
    set my_list to {"Published", "Working", "Published:PDF"}
    tell application "Finder"
    	set my_folder to reveal folder ((path to desktop folder as text) & "325811-1:" )
    	select (every item of my_folder whose name is in my_list)
    end tell
    
    I'm trying to locate 'PDF' folder located under 'Published' folder. Any thought on how to do this
     

Share This Page