Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Deleting files without moving to the trash using AppleScript

Deleting files without moving to the trash using AppleScript
Thread Tools
Fresh-Faced Recruit
Join Date: Apr 2001
Location: Cairo, Egypt
Status: Offline
Reply With Quote
Jul 15, 2001, 04:40 AM
 
Assalamu 3alaikum,
I want to use an AppleScript command that would delete a file without having to move it to the trash. That is delete the file right away. I have an alias to the file and I guess I can also store it as text or whatever. What command shall I use? This is on OS X of course.I don't want to be asked whether or not I am sure if I want to delete a file. I want the file to be deleted right away

P.S- The command I used is delete. But that moves to the Trash

[ 07-15-2001: Message edited by: okandeel ]
     
Fresh-Faced Recruit
Join Date: Apr 2001
Location: Cairo, Egypt
Status: Offline
Reply With Quote
Jul 15, 2001, 06:19 AM
 
I also forgot to mention that I don't want to empty the trash. The script I am using is going to be inside an installer. So I don't want to force the user to empty the trash (by moving to the trash and then emptying it)

[ 07-15-2001: Message edited by: okandeel ]
     
Junior Member
Join Date: Apr 2001
Status: Offline
Reply With Quote
Jul 15, 2001, 07:32 AM
 
In standard applescript (without scripting additions), just like in Classic Mac OS, only the Finder can delete items - & only by moving them to the trash first & then emptying the trash. However, if you'll be replacing the deleted items with files/folders of the same name, you could skip the delete step & use "with replacing", which will replace items in the same folder with the same name as the items you're copying/moving, without asking for confirmation. For example:

tell application "Finder" to duplicate alias "MyDisk:MyFolder:MyFile" to desktop with replacing

Also, since in OS X the Unix "rm" command will do exactly what's needed here, a scripting addition such as OS X Power Additions Lite that allows implementing Unix commands within applescript could be used. The command would be something like:

Shell "rm -f /Users/Username/Desktop/MyFile"

This would, however, require that the scripting addition be installed on the computers of all users, which may not be what you're looking for. That is, the scripting addition would be a system requirement for users running the script. In OS 9, it was possible (with appropriate permission) to "bind" scripting additions to a script using a third party utility, so that the user would only need the bound script. As far as I know, this functionality isn't yet available in OS X, but hopefully will arrive soon from third party developers.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:13 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2