Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
I modified mysterytramp's and Wondersnite's code to allow one to delete a number of files (or just one file) from the trash. I found it to be kind of annoying to keep having to answer, yes, if I wanted to delete two or more files, for each file.

Code:
tell application "Finder"
	
	if button returned of (display dialog "Are you sure you want to permanently delete these files?" buttons {"Yes", "No"} default button "No") is "Yes" then
		
		get the selection
		
		if the number of items of the result < 1 then
			beep
		else
			repeat with theFile in the result
				set theVolume to the disk of theFile
				set itemPath to the (theFile as text)
				if ":.Trash" is in itemPath then
					do shell script "rm -r " & (quoted form of POSIX path of itemPath)
				else
					beep
				end if
			end repeat
		end if
	end if
end tell

Thank you -aggie-, this code is just perfect. I also checked and it even works if you are deleting items from various volumes. Now it works exactly as it should :) Of course, now that theVolume variable is redundant, so I guess the final version of the script should be:

Code:
tell application "Finder"
	set theSelection to the selection
	if the number of items of theSelection < 1 then
		beep
	else
		if button returned of (display dialog "Are you sure you want to permanently delete these files?" buttons {"Yes", "No"} default button "No") is "Yes" then
			repeat with theFile in theSelection
				set itemPath to the (theFile as text)
				if ":.Trash" is in itemPath then
					do shell script "rm -r " & (quoted form of POSIX path of itemPath)
				else
					beep
				end if
			end repeat
		end if
	end if
end tell

I've using this with Spark, it works flawlessly ;)
 
Hehehe...dont get so angry with me. I told that this was a stupid question but I had this feature in Windows so I just thought if its available in Mac too!!!

I don't think this question is stupid at all. I see most people are explaining the work arounds rather than offering the right answer. I myself find myself in situatons where I would like to permanently delete certain items and leave some items in the trash folder (maybe I am unsure if I want to get rid of something immediately.. maybe I am just weird that way), but Macbook doesn't do a good job as compared to windows when it comes to selectively cleaning up the trash bin
 
Because if you don't actually want to delete something, it shouldn't be in the Trash.

Why have a trash at all in that case ? The whole point of trash over a direct delete is that it is for something you are unsure about deleting.
 
Call me naive, but I just use the trash like a regular trash can. I only put things in it that I expect to be removed (deleted) from the HD. Each day I empty the trash to keep it nice and clean just like a real trash can.

I've never understood storing files in the trash. If I am not sure what I want to do with a file, I put it in a folder on the desktop for later review.

For me, it keeps things simple this way.
 
...

I've never understood storing files in the trash. If I am not sure what I want to do with a file, I put it in a folder on the desktop for later review.

...
Look at it from the perspective of a Windows user. The folder hierarchy of Windows is difficult to access and navigate. OTOH, the Trash Bin is on the Desktop and easily accessible. It is easier to access a file in the Trash Bin than almost anywhere else in the Windows folder hierarchy except the Desktop.

Compare this to the Mac. The folder hierarchy of MacOS X is easy to access and navigate. The user may place a folder [or its alias] on the Desktop, the Dock, and/or the Finder window sidebar making it even more accessible. The Trash is no more accessible than any other folder.

The takeaway message is that file storage in the Trash Bin is a workaround for the deficiencies of Windows. Mac users don't understand it because we don't have to deal with these problems.
 
And if you really want to delete something without putting it in the Trash first, open Terminal, type "rm -rf", drag the file into the Terminal window and hit Enter. Use at your own risk.

That's right. type
Code:
rm -i <filepath>
to delete a file without sending it to the trash. Like miles said, use at your own risk, as failing to include the -i option will cause the prompt to work silently, i.e. not asking you if you're sure you want to delete
 
Look at it from the perspective of a Windows user. The folder hierarchy of Windows is difficult to access and navigate. OTOH, the Trash Bin is on the Desktop and easily accessible. It is easier to access a file in the Trash Bin than almost anywhere else in the Windows folder hierarchy except the Desktop.

Compare this to the Mac. The folder hierarchy of MacOS X is easy to access and navigate. The user may place a folder [or its alias] on the Desktop, the Dock, and/or the Finder window sidebar making it even more accessible. The Trash is no more accessible than any other folder.

The takeaway message is that file storage in the Trash Bin is a workaround for the deficiencies of Windows. Mac users don't understand it because we don't have to deal with these problems.
Uh, I'm a Windows user (primary work platform) and don't store files in the Trash Bin.

As I said before, it makes no (logical) sense to me. The Trash Bin, Trash Can or whatever, is for putting files in that you are going to delete. Just like using a real trash can.

If you have files that you are not sure, then put them in a temp folder on the desktop.

Keeps things simple this way. :)
 
As I said before, it makes no (logical) sense to me. The Trash Bin, Trash Can or whatever, is for putting files in that you are going to delete. Just like using a real trash can.

Yes, but why have a trash can then? - you may as well just remove the files permanently straight away. The whole point of the trash can is that you can change your mind.
 
Yes, but why have a trash can then? - you may as well just remove the files permanently straight away. The whole point of the trash can is that you can change your mind.

Exactly. IDKY some Mac users defend this. Anyway, there are work arounds (see my posts up above), until Apple decides to add this feature (which they probably won’t).
 
Yes, but why have a trash can then? - you may as well just remove the files permanently straight away. The whole point of the trash can is that you can change your mind.
It's called a mistake. Sometimes items are Trashed by mistake. The Mac Trash can provides the opportunity for the user to retrieve mistakenly Trashed items. This is not a difficult concept for most users to understand.

Prior to System 7, the Trash was emptied upon shutdown. System 7 changed the Trash can to its current behavior.

BTW, items placed in a real Trash can stay there until you explicitly empty the Trash. However, people do not routinely place items that they intend to keep in their real trash cans or recycle bins.
 
Some of these responses really piss me off and makes me think most apple users must be some of the biggest idiots. They are the only ones that would wait in line for days to be the first to trade in their working phone for a new defective phone.

Here's one reason why the bin should behave like windows: I got several huge screencast edits that are eating up 30 gigs of my HD space. I want to reclaim that space. I never empty my bin because i never know when I might need something down the line such as that document that has a chapter i forgot that i needed. if i move to a folder which i did, i can't restore to original location. I used to like macs but i'm starting to change my mind.

And i can't figure out why the stupid trash can't sort by date deleted.
 
It's called a mistake. Sometimes items are Trashed by mistake. The Mac Trash can provides the opportunity for the user to retrieve mistakenly Trashed items. This is not a difficult concept for most users to understand.

Prior to System 7, the Trash was emptied upon shutdown. System 7 changed the Trash can to its current behavior.

BTW, items placed in a real Trash can stay there until you explicitly empty the Trash. However, people do not routinely place items that they intend to keep in their real trash cans or recycle bins.

The whole point of this thread is to do with how long it is before people realised they have mistakenly deleted something. As you have pointed out, prior to System 7, the Trash was emptied upon shutdown, because it was assumed by Apple that most people would realise they have made a mistake before shutdown. This assumption was wrong, and Apple has rectified it. The assumption now is that people would realise they have made a mistake before they run out of disk space and need to empty their entire trash folder. What many people in this thread are saying is that this assumption is wrong. This should not be a difficult concept for most people to understand.

BTW your analogy of the Mac's Trash Folder with Real Trash Cans is a false analogy. The purpose of Real Trash Cans is NOT to act as a buffer, in case the user wish to retrieve items. It is merely a convenient device to save the user from walking all the way to the landfill every time an item needs to be dumped.
 
What's the use of Trash?

Some Mac users seem to want to throw anything away they put in the Trash.
Is this some form of masochism of having to do things twice? If I know for sure it can be thrown away, I want it to be one action...not two.

So what could be the possible use of a Trash can (or Recycle bin)?
To undo mistakes. And no I don't always recognize them when I do it.
The number one method of loosing data is still the person behind the computer.
So why is Recycle bin a crap? It's limited in size of a percentage of the hard drive and it's an explorer feature instead of an OS/file system feature.
So only if you delete from the explorer you have an escape if you made a mistake. If you did it from an app...you're busted. If you delete on a network drive..you're busted.

I have a NAS running Ubuntu, which does have an OS/file system based solution that moves any file that I delete (no matter how) to a recycle_bin.

Unfortunately it still doesn't stack documents, because deleting the entire contents of a document and then saving it....you're still busted.

So now back to the Trash.....it's to save my as if I made a mistake.
So I want to keep it as long as possible. Although Time-Machine may be defined the ultimate Trashcan since they invention of the computer.
So since Time-Machine I find it quite oke to have a Trash that empties itself after a few weeks.

Although it would be very nice that it would also contain documents that do not exist on the computer itself (USB-stick, USB-hard drive, NAS, remote-share) and that I deleted. That would be a nice addition, because these are NOT covered by Time Machine.

So do I still need to have a direct delete? YES, as long as there are video's, DVD images, system-backup-images that a Gigs in size.
Do I need to have a selective delete in the Trash? YES, as stupid as it may seem, I still want to be able to clean up the trash. I change my mind often and after a while I might be certain that I don't need it any more...or I might be certain that my wife does not need it any more.
Why do I need to clean up? I'm old fashioned and make full system backups once in a while and for performance reasons I want to keep them small.

If only Apple, Microsoft of who knows else, knew how to separate information into tidy partitions: system & apps (for purist even separated in 2), data, temp.
The trash would then be in the temp if I could choose.
Time Machine would be the master of recovery in data, in combination with Trash.
DiskDuper/CarbonCopy together would be the masters of the system&apps partion.

So Apple please make users happy:
a) Implement the delete-direct
b) Implement delete from Trash
c) Implement also deletion from other sources
d) If it wasn't for Time Machine I would also like to have a versioning
if the file would be overwritten.
 
Deleting selected items from Trash

I can't believe that people have an issue with how the Apple chooses to handle the Trash. Just because Microsoft does it one way does not mean Apple should do it that way too. There are MANY "features" in Windows that many people use that should not be added to the Mac OS.

The trash should be treated as trash. Don't put something in the trash if you think you might need it later. Is it so hard to create a folder called "Recycle Bin" and put stuff in there you think you don't need but aren't sure about? Yes, you will have to move any files manually to the "Recycle Bin" but so what?

It's a Mac. Learn how to use it.......

S-

OS X does have a lot of things better than Windows, which is the reason I use a MAC. However Trash is a stupid implementation, IMO, even if Apple wants users to "put back" items in Trash to handle accidental deletes, this is not done properly. I see the "put back" for a few delete items and not for the rest. I have to manually restore items that do not have the "Put Back" option. In addition to not having selected items to delete, Trash becomes real painful to use.
 
Updated script

I agree, not being able to delete selected files from the Trash is a glaring omission to an otherwise great operating system. That, and any-corner window resizing.

I've updated the script a little. Works on Snow Leopard - haven't tried it on other systems. Main update is it now shows a list of files about to be deleted, and asks for confirmation one time only. It also contains some better error checking.

The easiest way to setup it up on Snow Leopard in my opinion is shown in a few steps below. Note: When using this method you will need to run the app from your Dock, preferably from within the Applications folder you should have already on your Dock. It won't work if you run it from a Finder window. For Leopard/Tiger users use another way of saving & running the script.

1) open Automator in Applications/Utilities
2) select "Application" from the new file wizard that shows up
3) drag "Run AppleScript" from the long list on the left side to the main window on the right side
4) delete the text in the window and replace it with the script below
5) save your new apple script text to your applications folder, call it "Delete From Trash" or something similar.

Updated script:


Code:
tell application "Finder"
	
	set theSelection to (selection)
	
	if number of items in the theSelection < 1 then
		display dialog "No file(s) selected." buttons {"OK"} default button "OK"
		return
	end if
	
	set fileListText to "Delete the following trash files?" & return & return
	
	set numFilesToDelete to 0
	
	repeat with theFile in theSelection
		try
			set itemPath to the quoted form of POSIX path of (theFile as alias)
		on error
			display dialog "Could not get selected files." buttons {"OK"} default button "OK"
			return
		end try
		if ".Trash" is in itemPath then
			set theVolume to the disk of theFile
			set theDisplayedName to the displayed name of theFile
			set fileListText to fileListText & "  " & (theVolume as text) & " " & (theDisplayedName as text) & return
			set numFilesToDelete to numFilesToDelete + 1
		end if
	end repeat
	
	if numFilesToDelete is 0 then
		display dialog "No files selected in the Trash." buttons {"OK"} default button "OK"
		return
	end if
	
	if button returned of (display dialog fileListText buttons {"OK", "Cancel"} default button "Cancel") is "Cancel" then
		return
	end if
	
	repeat with theFile in theSelection
		set itemPath to the quoted form of POSIX path of (theFile as alias)
		if ".Trash" is in itemPath then
			do shell script "rm -r " & itemPath
		end if
	end repeat
	
end tell


Hope it works ok for yous...
 
Last edited by a moderator:
I agree, not being able to delete selected files from the Trash is a glaring omission to an otherwise great operating system.

Perhaps it is... for folks who don't understand what a Trash container is. Let me ask you this: do you rummage through the trash in your kitchen and select specific items to carry outside?

Folks, if that is how you conduct "file management" then create a folder on the desktop called Junk, and put the stuff about which you feel so ambiguous in there first... and then move it into the real trash, when your feelings are more resolute.
 
Its a computer operating system not a kitchen. Anyway enough has been said in previous posts about this so I'm not going to bother commenting further.
 
Its a computer operating system not a kitchen. Anyway enough has been said in previous posts about this so I'm not going to bother commenting further.

Hey, very nice script and all that... no offense meant. I just thought that the phrase "glaring omission" was overstating the case. Some things are good when built into the OS, and other things are best left up to 3rd-party solutions.
 
I can see where the original poster was coming from. There is a much simpler method to solve this. Personally I have literally a pre-trash folder. Stuff I may need for a short while until it happens, then the file is trash. Things in this category are order receipts for items, I save as PDF's and then when they arrive I no longer need the file. Or a pic of something I may sell on eBay. Once a month or so, I pull the doomed files to the real trash and empty it. Easy to do the Command-Click to selectively get the files and drag and drop. I even got a clever icon to put on this folder, a representation of the locker on 'Lost.'
 
Dogpilot, you are (inadvertently perhaps) pointing out more than anyone else why the OSX trash system is not ok.

I hope someone from Apple is looking at this thread. Its been going on for years. I found it today as I needed to remove some huge files from the trash (to save space) and didn't want to empty it completely (for my own reasons).

Also Mr. Apple guy/girl if you are reading, you need to add a "really delete" function too (maybe with option pressed in the right click menu) - this is a must for USB pendrives and more.

Actually, come to think of it, the USB pen drive scenario sums the problem up completely. Its just bad design that it is not possible for a normal/casual user (ie. no scripts or terminal or fancy key combinations) to delete files from a USB drive without emptying the trash of the entire system. Keep in mind that there are no "move" or "cut" commands either (yes there are ways, but not for a casual user).

Very possible scenario:
  • Yesterday: User deletes important document by accident (whole reason for trash feature in the first place)
  • Today: User has to copy a large file to another (friend's/wife's) computer using a USB pendrive ... pendrive is full from previous use .. user deletes all files on the pendrive to make space ... still no space available on pendrive ... has to empty the trash as no other option available
  • Tomorrow: damn - where's that important doc???
 
Another more common scenario

"so I'm not going to bother commenting further"
Well so much for that - I tried though...

Just though of another much more common scenario:

  • Husband and wife or boyfriend and girlfriend use same Mac computer and share the same account as the computer is always on and they couldn't be bothered logging in and out all the time - anyway they have no secrets from each other (my parents do this on their PC so don't say its not common).
  • Both are "casual" users (no scripts/terminal/advanced knowledge).
  • Trash gets used by both users and may contain important accidentally deleted documents of either user.
  • Husband/Boyfriend alone one day downloads some stuff for his own personal use. He now wants to delete these files as the wife/girlfriend may not like them. Really delete them. Only one way that he knows...
  • Next day... damn where's that doc??? why did you empty the trash??? etc.
 
Well so much for that - I tried though...

Just though of another much more common scenario:

  • Husband and wife or boyfriend and girlfriend use same Mac computer and share the same account as the computer is always on and they couldn't be bothered logging in and out all the time - anyway they have no secrets from each other (my parents do this on their PC so don't say its not common).
  • Both are "casual" users (no scripts/terminal/advanced knowledge).
  • Trash gets used by both users and may contain important accidentally deleted documents of either user.
  • Husband/Boyfriend alone one day downloads some stuff for his own personal use. He now wants to delete these files as the wife/girlfriend may not like them. Really delete them. Only one way that he knows...
  • Next day... damn where's that doc??? why did you empty the trash??? etc.
Multiple bad practices. You don't mitigate one bad practice by developing a second or third bad practice--unless you are Microsoft and developed Windows. What is incredible is that MacOS X is so amazingly designed that there is no downside to doing things properly. However, you insist on doing them improperly. Keep on insisting because Apple will not convert the Trash into an all-purpose storage bin. Also if you keep on insisting, then I will be forced to explain exactly why this dumb practice came into being and which dumb Microsoft decisions it was developed to compensate for. You wouldn't like that:p
 
Yet another scenario

  1. User deletes important doc by accident.
  2. User's cousin (casual user) comes to visit for a few days.
  3. User's cousin wants to use Users's mac to check his email.
  4. User's cousin downloads a personal email attachment while doing this.
  5. User's cousin wants to really delete the email attachment when finished - only one way he knows how...
  6. Later... User cannot find that important doc he accidentally deleted.

I think it is a glaring omission that one of the best operating systems around has no user friendly way to really delete a file or group of files from the system. Its all or nothing. Its a very basic privacy/security feature - the ability to really delete a file. Its also a very basic operating system feature to have a trash can or recycle bin as mistakes can and will happen.

In OSX there is no user friendly way to have both these features. You have to compromise - you get either lack of privacy/security (some file you don't want around is still on your computer) or no accident protection whatsoever (have to delete the entire trash can when you may not want to).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.