无法在 Apple 脚本中找到指定应用程序的应用程序支持文件夹

发布于 2025-01-14 17:16:51 字数 211 浏览 3 评论 0原文

我有一个苹果脚本,要求用户选择一个应用程序作为提示。我想知道如何找到该应用程序的应用程序支持文件夹的目录,例如 Spotify 是 ~/Library/Application Support/Spotify/

在我的 mac 上,但就像苹果脚本中有一种方法可以找到特定应用程序的此目录。真的很感激,谢谢!

因为我想然后使用 Apple 脚本删除这个文件夹

I have an apple script that asks the user to select an application as a prompt. I would like to know how it could be possible to find the directory of the Application Support folder for this application per example, Spotify is
~/Library/Application Support/Spotify/

On my mac, but like is there a way inside apple script to find this directory for the specific app. It would really be appreciated, thanks!

Because I would like to then delete this folder using Apple Script

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独﹏钓一江月 2025-01-21 17:16:51

这应该可以实现您想要实现的目标。但要小心,因为使用系统事件删除...会永久删除该项目,而不是将其发送到垃圾箱

property folderNames : missing value

tell application "System Events"
    set appSupportFolder to application support folder
    set folderNames to name of folders of appSupportFolder
    set theChoice to my chooseFolderToDelete()
    delete folder theChoice of appSupportFolder
end tell

to chooseFolderToDelete()
    activate
    set theChoice to (choose from list folderNames with prompt ¬
        "Select an Application's Support folder to delete" OK button name ¬
        "Delete Folder" cancel button name "Cancel") as text
end chooseFolderToDelete

This should accomplish what you're looking to achieve. Be careful though because using System Events to delete... deletes the item permanently instead of sending it to the Trash

property folderNames : missing value

tell application "System Events"
    set appSupportFolder to application support folder
    set folderNames to name of folders of appSupportFolder
    set theChoice to my chooseFolderToDelete()
    delete folder theChoice of appSupportFolder
end tell

to chooseFolderToDelete()
    activate
    set theChoice to (choose from list folderNames with prompt ¬
        "Select an Application's Support folder to delete" OK button name ¬
        "Delete Folder" cancel button name "Cancel") as text
end chooseFolderToDelete
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文