How to get POSIX path of the current script's folder in JavaScript for Automation?
问题 In AppleScript it’s possible to get the the POSIX path of the folder the current script is located in using this line: POSIX path of ((path to me as text) & "::") Example result: /Users/aaron/Git/test/ What’s the JavaScript equivalent? 回答1: Here's a way [NOTE: I NO LONGER RECOMMEND THIS METHOD. SEE EDIT, BELOW] : app = Application.currentApplication(); app.includeStandardAdditions = true; path = app.pathTo(this); app.doShellScript('dirname \'' + path + '\'') + '/'; note the single quotes