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

时间:2010-05-27 02:30:45

标签: cocoa applescript

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

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

2 个答案:

答案 0 :(得分:1)

由于垃圾箱只是主文件夹中的一个隐形文件夹,你可以这样做......

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

答案 1 :(得分:-1)

一种简单的方法(不会移动到垃圾箱)

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