2015-06-22 2 views
0

Я пытаюсь запустить окно Finder в папке, которая находится в том же каталоге, что и мой скрипт. Когда я запускаю код ниже, он запускает пустое окно Finder, установленное на путь сценария, а не в папку.Путь AppleScript относительно места расположения сценария

tell application "Finder" 
    tell application "Finder" to make new Finder window 
    set file_path to (path to me) as text 
    set target of Finder window 1 to file_path 
end tell 

Как я могу получить путь к папке сценария, а не сценарию?

+0

не вы уже спрашивали то же самое? http://stackoverflow.com/questions/30789060/play-sound-with-applescript-using-afplay-and-relative-file-path –

ответ

1

Вы были близки. Вам не нужно текстовую версию файла, вам нужно только сам файл, то вы можете попросить Finder для контейнера этого файла:

tell application "Finder" 
    tell application "Finder" to make new Finder window 
    set file_path to (path to me) 
    set target of Finder window 1 to file_path's container 
end tell 
1

Самый короткий путь я знаю, чтобы сделать это:

tell application "Finder" to open ((path to me as text) & "::") 

Редактирование сценария делает следующее:

tell application "Finder" 
    make new Finder window -- There is no need for an your second tell statement 
    set file_path to (path to me as text) & "::" -- Goes up one directory 
    set target of Finder window 1 to file_path 
end tell 
Смежные вопросы