Any way to get Trash to tell me the number of items?

Discussion in 'Mac Basics and Help' started by xfusejc, May 19, 2007.

  1. xfusejc macrumors 6502

    Joined:
    Dec 29, 2006
    #1
    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?
     
  2. orangemacapple macrumors 6502

    Joined:
    Sep 1, 2006
    Location:
    Raleigh
    #2
    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.
     
  3. Deepdale macrumors 68000

    Deepdale

    Joined:
    May 4, 2005
    Location:
    New York
    #3
    A reply to a straightforward question is best when an amateur psychiatric diagnosis is left out.
     
  4. orangemacapple macrumors 6502

    Joined:
    Sep 1, 2006
    Location:
    Raleigh
    #4
    quite true. my apologies. i'm in rare form tonight.
     
  5. M@lew macrumors 68000

    M@lew

    Joined:
    Nov 18, 2006
    Location:
    Melbourne, Australia
    #5
    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.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    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

    Code:
    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!

    Code:
    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
    
     

Share This Page