Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Empty trash without Preview blocking a file Apps
After opening a file with Preview, the app blocks it (marks it as in use) until you quit Preview. To easily empty the trash without manually switching back to Preview and closing everything, I found finally this (simple) solution. Open Script Editor and create this AppleScript:
tell application "Preview"
quit
end tell

tell application "Finder"
empty trash
end tell
This simple AppleScript does the work, and with the free application Spark, it's only a keypress away from activation.
    •    
  • Currently 1.43 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[8,596 views]  

Empty trash without Preview blocking a file | 13 comments | Create New Account
Click here to return to the 'Empty trash without Preview blocking a file' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Empty trash without Preview blocking a file
Authored by: jelockwood on Jan 16, '09 08:17:56AM

This problem also affects QuickTime Player and is down to a bug. I reported this bug to Apple back in the Mac OS X 10.4.x era and they confirmed its existence but certainly as of 10.4.11 with the latest QuickTime etc. it still occurs.

I have not yet tried reproducing it under 10.5 so I don't know if it is fixed there but judging from the posting of this hint I would guess the answer is no. [It does not occur 100% of the time, but if you have Preview/Player running long enough and open/close enough files it will rear its ugly head]

While this is a minor bug, it is disappointing Apple have taken so very long to still not yet fix it. I thought only Microsoft were guilty of that. ;)



[ Reply to This | # ]
Silliness
Authored by: Black on Jan 16, '09 08:24:57AM

I can't actually duplicate the conditions under which this is necessary. I opened a file in Preview, closed it without quitting preview, dragged it to the Trash, and then emptied the Trash. No problem. It complained when the file was still actually open in Preview, but that is hardly surprising (I'd be surprised if it didn't complain), and is by no means restricted to Preview.

Even if this was an issue with Preview, I fail to see why this is particularly helpful. I wouldn't want to quit Preview every time I emptied the Trash on the off chance that it might still be hanging on to a file. Even if it is, everything else will still be deleted and if there is some urgency to deleting the one troublesome file, it is not exactly taxing to quit Preview. But like I said, I can't duplicate the problem. This hint would be better if rather than the pretty silly "solution" it just said: "If you can't delete a file that was recently open in Preview, try quitting Preview, it might still be holding a reference to it."



[ Reply to This | # ]
Does this also affect ejecting volumes?
Authored by: whoadoggy on Jan 16, '09 09:32:10AM

often a volume will refuse to eject even though no files are obviously open. Many hints here on that, but it would be useful to know if Preview is a common culprit.



[ Reply to This | # ]
Not really a solution
Authored by: ars on Jan 16, '09 10:13:22AM

I tested this too and it did not happen for me either. I do remember that it did sometimes happen in the past, but this applescript does not really solve the problem. If only shortens the number of mouse clicks you make to do the same thing, namely quitting Preview and then emptying the Trash. A real solution would make that Preview does not have to be quit to empty the trash.



[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: leamanc on Jan 16, '09 11:02:50AM

This was a lot bigger problem back in the classic Mac OS days, basically applicable to any application and any file it had opened.

I only notice it with Preview (as noted in the hint), QuickTime Player (as noted above) and TextEdit.

It's usually not a big deal for me to cmd-tab over to the offending app, cmd-q, empty trash and go about my business.



[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: el_mancebo on Jan 16, '09 12:26:05PM

I select "empty secure trash" in the finder menu, and all blocked files are trashed out, even the movies playing in Quicktime....



[ Reply to This | # ]
I wrote exactly the same script and run it with Spark
Authored by: tice on Jan 16, '09 01:05:50PM
A long time ago I faced the same problem over and over again and came to the same solution. Just insert the script in the freeware Spark and emtying the trash is just pressing a button (I use F12 and set it to "-" in the system preferences).

[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: piyayo on Jan 17, '09 07:43:47AM

Thanks for the hint but I don't think quitting the whole app is the solution when most of the time I have many documents open in Preview.

That being said, I really appreciate hints with code snippets. Writing anything even slightily involved in Applescript is such a nightmare I don't think I could have done without this site.



[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: jiclark on Jan 17, '09 09:44:45AM

So my question is, why do some people experience this issue, but others don't? If it were truly a bug, it would be reproducible pretty much universally...

It sounds like a system setting somewhere is causing the problem, maybe?



[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: rottenchops on Jan 19, '09 09:38:21AM
If it were truly a bug, it would be reproducible pretty much universally... Wha? I disagree.

[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: jiclark on Jan 20, '09 12:43:00PM

If a significant percentage of people don't experience the issue, then it becomes much more likely that the problem is caused by some unique set of circomstances on a given machine, rather than a OS-specific bug. It would also make it quite likely that Apple can't reproduce it (consistently anyway) in their testing environment, which explain why no "fix" has been forthcoming...



[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: jelockwood on Jan 21, '09 08:53:59AM

I originally reported this (bug) to Apple with regards to QuickTime Player as Radar number 5544934 in October 2007.

I then later reported the same problem for Preview as Radar number 5779199 which subsequently Apple labelled as being a duplicate of someone else's Radar number 5575851.

I would have to dig through ancient emails, but I recall a response from Apple with regards to QuickTime Player that it was supposedly fixed in a software update (but the problem subsequently came back after another update). As there are two different Radar bug reports for the Preview version, it was certainly on Apple's 'radar' (groan!).



[ Reply to This | # ]
Empty trash without Preview blocking a file
Authored by: sjmills on Jan 19, '09 07:42:45PM

How does this help if Preview isn't the app that's preventing a file from being opened? You'd have to write a similar script for every app that does this, then remember which apps have been launched with the troublesome files and then remember how to launch those scripts. Man, the community must be hurtin' for hints if this is what it's come down to.



[ Reply to This | # ]