PDA

View Full Version : Any way to get Trash to tell me the number of items?




xfusejc
May 20, 2007, 01:48 AM
I've seen it before in other computers (just not sure if they were MAC or PC) but it's a small bubble with the Trash can that basically says the amount of items it contains. Like, I deleted 12 pictures, the trash will appear full with a little number 12 on it. Any way to get this to happen?



orangemacapple
May 20, 2007, 02:18 AM
i think i saw a little utility like that somewhere, but i can't remember where.

it just strikes me funny that somebody would want to count their trash.

i really don't see the usefulness in it. once you throw something in the trash, you shouldn't care about how much is in there -- just empty it once in awhile.

maybe you should seek therapy -- sounds like you have a case of OCD. they make medications for that.

do you also dumpster-dive for your christmas presents? that's a fun hobby, too. and don't forget the landfills have lots of treasures.

Deepdale
May 20, 2007, 02:48 AM
... maybe you should seek therapy -- sounds like you have a case of OCD. they make medications for that.

A reply to a straightforward question is best when an amateur psychiatric diagnosis is left out.

orangemacapple
May 20, 2007, 03:06 AM
A reply to a straightforward question is best when an amateur psychiatric diagnosis is left out.

quite true. my apologies. i'm in rare form tonight.

M@lew
May 20, 2007, 03:50 AM
Dragthing allows you to have a little icon of the trash on your desktop which says the amount etc.

But I personally think it looks ugly and is unnecessary.

robbieduncan
May 20, 2007, 04:14 AM
The following Applescript will display a count of the top level items in the Trash. Note that this is not the same as the total count of the items: a folder 1 with 100 items in the Trash will count as 1 item (the folder). You could alter it to traverse all the folders and count the contents, but that's an exercise for the reader :D


tell application "Finder"
set i to count of items in trash
end tell

if (i = 1) then
display dialog "There is 1 item in the trash"
else
display dialog "There are " & i & " items in the trash"
end if


Edit to add: So I'm procrastinating and this was the perfect excuse not to do what i'm actually meant to be doing! The below should count all items in the trash correctly. It doesn't count folders as items (although you could add this easily), but it does count the items inside folders (and should work with items in folders in folders and so on). Note that this means that an empty folder won't get counted at all!


on countFolder(inFolder)
set cont to contents of inFolder
set localCount to 0
repeat with anItem in cont
if ((class of anItem as string) is equal to "folder") then
tell me to countFolder(anItem)
set localCount to localCount + result
else
set localCount to localCount + 1
end if
end repeat
return localCount
end countFolder

tell application "Finder"
set trFolder to trash
tell me to countFolder(trFolder)
set totalCount to result
end tell

if (totalCount = 1) then
display dialog "There is 1 item in the trash"
else
display dialog "There are " & totalCount & " items in the trash"
end if