AppleScript choose file or folder

前端 未结 2 1408
感动是毒
感动是毒 2021-01-13 07:40

can I use AppleScript to choose either file or folder in one time?

Now I could use

tell application \"SystemUIServer\" to return POSIX path of (choo         


        
2条回答
  •  被撕碎了的回忆
    2021-01-13 08:10

    Firstly, you don't need a tell for that.

    POSIX path of (choose file)
    

    Secondly, it is not clear why you need this. Do you mean you want to select a file and it's folder? That's not how you do it; you select the file then parse the file path for the containing folder or use one of the many methods to do that, like

    set f to (choose file)
    set posixF to POSIX path of f
    tell application "Finder" to set filesDir to container of f as alias as text
    set posixDir to POSIX path of filesDir
    
    {f, posixF, filesDir, posixDir}
    

    If you want to be able to select multiple folders and files at the same time, I don't think there is a "pure applescript" way to do this (aside from using a drag-drop aware script application).

提交回复
热议问题