Undoubtedly. Am trying to avoid the Finder though. The work around I have is to append the date/time to the trashed folder’s name. This avoids the issue.
You can disable all Finder sounds in the sound PrefPane or if you want to keep all sounds
except the trash sound, replace the specified sound file with a “silent” one
That’s an idea. But I really only want to temporarily disable the sound for the purposes of a script.
I have played around with the following script:
beep
set gg to alert volume of (get volume settings)
set alert volume of (get volume settings) to 0
delay 1
beep
set alert volume of (get volume settings) to gg
delay 1
beep
But it does not do what I was hoping. Is there any way to set the volume alert value of (get volume settings)? This would be the best way so that music or anything else going on when the script runs, will not be affected.
I guess you don’t want to use the «rm» command to permanently delete the folder, as you want to enable the user to retrieve the deleted folders from the trash.
If you don’t want to use the Finder, then you can also use code as follows to silently move a directory to the trash. The handler makes use of the «ditto» command to copy the directory to the trash folder. If the folder name of the directory already exists in the trash folder, the script adds a counter to the name (‘foldername’ => ‘foldername 1’).
set srcfolder to "DandyDisk:Users:martin:Desktop:test:"
set success to my trashfolder(srcfolder)
on trashfolder(srcfolderpath)
try
set trashfolderpath to ((path to trash) as Unicode text)
set srcfolderinfo to info for (srcfolderpath as alias)
set srcfoldername to name of srcfolderinfo
set srcfolderpath to quoted form of POSIX path of srcfolderpath
set counter to 0
repeat
if counter is equal to 0 then
set destfolderpath to trashfolderpath & srcfoldername & ":"
else
set destfolderpath to trashfolderpath & srcfoldername & " " & counter & ":"
end if
try
set destfolderalias to destfolderpath as alias
on error
exit repeat
end try
set counter to counter + 1
end repeat
set destfolderpath to quoted form of POSIX path of destfolderpath
set command to "ditto " & srcfolderpath & space & destfolderpath
do shell script command
-- this won't be executed if the ditto command errors
set command to "rm -r " & srcfolderpath
do shell script command
return true
on error
return false
end try
end trashfolder