首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Applescript打开用户的库文件夹

使用Applescript打开用户的库文件夹
EN

Stack Overflow用户
提问于 2014-05-13 13:40:38
回答 3查看 5.8K关注 0票数 3

我想打开一个默认为应用程序的设置文件夹的文件夹:

代码语言:javascript
复制
/Users/XXX/Library/Application Support/Tunnelblick/Configurations

我不想“硬编码”'XXX‘。

/library文件夹:

代码语言:javascript
复制
set theDestination to (choose folder with prompt "Open destination folder" default location (path to library folder))

home文件夹:

代码语言:javascript
复制
set theDestination to (choose folder with prompt "Open destination folder" default location (path to home folder))

我不知道如何获得~/Library文件夹及其一个子文件夹。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-05-13 14:06:07

通往图书馆的途径是:

代码语言:javascript
复制
POSIX path of (path to library folder from user domain)

=~/图书馆/

代码语言:javascript
复制
POSIX path of (path to library folder from local domain)

=/图书馆/

代码语言:javascript
复制
POSIX path of (path to library folder from system domain)

=/系统/图书馆/

票数 4
EN

Stack Overflow用户

发布于 2014-05-13 15:31:05

系统还知道应用程序支持文件夹:

代码语言:javascript
复制
set aFolderPath to ((path to application support folder from user domain) as text) & "Tunnelblick:Configurations:"
try
    set destinationPath to aFolderPath as alias
on error
    beep
    log aFolderPath & " missing"
    return
end try
set theDestination to (choose folder with prompt "Open destination folder" default location destinationPath)

StandardAdditionspath to

代码语言:javascript
复制
path to v : Return the full path to the specified folder
path to application support/applications folder/desktop/desktop pictures folder/documents folder/downloads folder/favorites folder/Folder Action scripts/fonts/help/home folder/internet plugins/keychain folder/library folder/modem scripts/movies folder/music folder/pictures folder/preferences/printer descriptions/public folder/scripting additions folder/scripts folder/services folder/shared documents/shared libraries/sites folder/startup disk/startup items/system folder/system preferences/temporary items/trash/users folder/utilities folder/workflows folder/voices/apple menu/control panels/control strip modules/extensions/launcher items folder/printer drivers/printmonitor/shutdown folder/speakable items/stationery : the folder to return
[from system domain/local domain/network domain/user domain/Classic domain] : where to look for the indicated folder
[as type class] : the type to return: alias or string (default is alias)
[folder creation boolean] : Create the folder if it doesn’t exist? (default is true)
→ alias : the path to the specified folder
票数 1
EN

Stack Overflow用户

发布于 2014-05-13 13:57:45

已解决:

代码语言:javascript
复制
set theDefault to (path to home folder as text) & "Library:Application Support:Tunnelblick:Configurations" as alias

set theDestination to (choose folder with prompt "Open destination folder" default location theDefault)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23632885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档