在 Applescript 中删除文件而不播放声音?

发布于 2024-09-03 11:17:09 字数 196 浏览 2 评论 0原文

tell application "Finder"
    set deletedfile to alias "Snow Leopard:Users:test.pdf"
    delete deletedfile
end tell

问题是我从 Cocoa 应用程序中重复调用此脚本,因此声音也会重复播放。是否可以禁用该声音?

tell application "Finder"
    set deletedfile to alias "Snow Leopard:Users:test.pdf"
    delete deletedfile
end tell

The problem is I repeatedly call this script from my Cocoa application so the sound is played repeatedly too. Is it possible to disable that sound ?

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

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

发布评论

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

评论(2

┾廆蒐ゝ 2024-09-10 11:17:09

由于垃圾箱只是您主文件夹中的一个不可见文件夹,因此您可以执行以下操作...

set myFile to (path to desktop folder as text) & "myFile.txt"
set trashFolder to path to trash folder from user domain

do shell script "mv " & quoted form of POSIX path of myFile & space & quoted form of POSIX path of trashFolder

Since the trash is just an invisible folder inside your home folder you can do this...

set myFile to (path to desktop folder as text) & "myFile.txt"
set trashFolder to path to trash folder from user domain

do shell script "mv " & quoted form of POSIX path of myFile & space & quoted form of POSIX path of trashFolder
从此见与不见 2024-09-10 11:17:09

一种简单的方法(不移至垃圾箱)

do shell script "rm '/Users/test.pdf'"

one simple way (doesn't move to Trash)

do shell script "rm '/Users/test.pdf'"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文