Check/Empty All Trashes

This is inspired by @paulwaldo’s post and is a slightly extended version of my mini macro.

In addition to showing the sizes of your different Trash folders it now can also…

  • list or show the content of the Trash (for each volume),
  • empty the Trash of each volume separately,
  • empty the Trashes selectively, by file age and size

It comes with a comprehensive help text. (Click the Help button.)

Download


Please see @Tom's update below:
Version 1.2 2019-04-11


Edit [2016-03-07]: Uploaded a new version (mainly corrections in the help text) and added a png of the macro here.


User prompt:


Trash log (or preview):


Macro:

4 Likes

Impressive! Definitely one I’ll be going over for inspiration as well :smiley:

It’s also usable :wink:

Already did! Was just looking over the help section, looking great!

Really nice showcase of what KM can do, @Tom! I tried to get the filters to work, but had no luck. For example, I chose Files Bigger Than 100G and got a full list of my only 16GB trash. I also tried Last Time Stamp of 1s and still got the full list. Am I misunderstanding?

Just out of curiosity, why the repeat of 12?

If you enter 1s it is correct that you get the whole trash content listed. (Probably every file in the Trash will have an access date older than 1 second.) The conditions are explained in the help text.

But this doesn’t explain the 100G. (Unless you have combined it with the 1s, since these are OR conditions!)

Is the entry field clean? You must only enter the value and the unit symbol like in the screenshot above, optionally a ‘+’ or ‘-’ prefix. In fact, a value without prefix counts as ‘+’ (bigger than or older than), any other char before the value counts as ‘-’ (smaller/younger). Maybe you have a space character or something in front of the “100G”? [Edit:] Nope, this isn’t true. A space character would be OK, and any other character other than +/- will raise an error. So this can’t be the reason.

If not, are you sure that the listed items are not only a lot of .DS_Store files and empty folders? These are always deleted if you enter any condition (see the last section in the help text).

Just out of curiosity, why the repeat of 12?

Oh, that’s the number of external disks the average Mac user has connected :slight_smile:

No, the reason is that I somehow just felt better with a lower number than with 999. If you never want the user prompt to reappear after the first run, just set it to 1.

Let me know if you get it to work.

Tom

@tom, here is what I am entering

and this is the output

Nothing near the size of 100 GB there!

Have a closer look at your output screenshot: It’s what I supposed above, only .DS_Store files or empty folders. (“Data” is an empty folder inside the numbers package.)

So, what you are seeing is the expected behavior.

If you choose a timestamp or a size filter the macro will always delete .DS_Store files and empty items. Otherwise —when you repeatedly empty the Trash with these filters— you would end up with a Trash full of .DS_Store and empty folders, because usually they’ll never pass the filters: For the typical size filter they are too small and the access time stamp of folders gets updated every time you run the macro.

But it’s largely useless to have thousands of .DS_Store files and empty folders in the Trash, that’s why I delete them, even when a size/age condition is set.

(If you click the Help button the macro will open a short description text. This, and other things, are covered there, too.)

Try it with more sensitive filters, like 2d and/or 5M, for example.

Tom

Yes, you are right @Tom, I should have looked at those items more carefully. I see now that they are folders and .DS_Store files only. Thanks for the clarification :grinning:

Update 2019-04-11

Version 1.2

All Trashes.kmmacros (94.2 KB)

Changes:

  • Unit symbols for file size and time stamp are now case insensitive:
    • Valid unit symbols for size: k, K; M, m; G, g; T, t; P, p
    • Valid unit symbols for time: s, S; m, M; h, H; d, D; w, W

Reason for the change: I’m getting old and I catched myself trying to enter K instead of k, and m instead of M too many times :wink:

Known issues:

  • There is an alignment glitch in the tabulated display of the disks/trashes, depending on the amount of figures in the displayed values. This is a cosmetic glitch only. I will fix it when I find the time.

BTW, over the course of time —the macro was first posted 3 years ago—I’m wondering why the macro (or similar KM macros by other authors) is not getting more feedback. This macro can fully replace commercial apps like the €9 Smart Trash, and probably some more. (I’m not complaining, but trying to invite you to use/write KM macros instead of buying other apps that do the same or less :wink: )

1 Like

Thank you @Tom! I just noticed your update. I can't say I use this macro on a frequent basis, but I love it! Every once in a while I do want to see the size of my Trash or do a selective Trashing. It is also a great example of some nice KB magic. I thank you again for all the work that went into this!

Thanks for your feedback, @paulwaldo. I really appreciate this. This way at least I know that someone is using my tiny work and what he/she is thinking about it.

I don't do either. Maybe two times in three months or so. When I need it.

It is still irritating that Apple does not provide us with a simple GUI command to empty the Trash of one specific disk (e.g. a connected external disk).