applescriptfinder

Open info window in finder by applescript


I've some problems to find the correct apple script command: I want to open the info window for a given file or folder. It's that window which I can open via cmd+i in Finder. Now I want to be able to automate this action by script file. My code actually looks like this:

set aFile to POSIX file "/Users/xyz/Documents/test.rtf"
tell application "Finder" to open information window of aFile

But that doesn't work. The error message says that the file "information window of Macintosh HD:Users:xyz:Documents:test.rtf" cannot opened.


Solution

  • Some commands are picky with posix file. So we can coerce that to something else and it will work...

    set aFile to (POSIX file "/Users/xyz/Documents/test.rtf") as alias
    tell application "Finder" to open information window of aFile
    

    or

    set aFile to (POSIX file "/Users/xyz/Documents/test.rtf") as text
    tell application "Finder" to open information window of file aFile