Help me do this in Spotlight

Discussion in 'macOS' started by btrotter, Dec 11, 2009.

  1. btrotter macrumors newbie

    Aug 22, 2008
    I am trying to figure out how to do something using Spotlight and am not having any luck. Can you give me a hand?

    I would like to search my hard disks for all files that end in a certain file type (example: .jpg), and show the total size of them.

    If I type in jpg in Spotlight, it shows all the files. At the bottom, I can see where it says "more than 10,000 found"

    However, if I want to look at the file size of a single file, I have to right click it, and select Get Info. If I select View, Show View Options, Size is grayed out to where I cannot select it. So I cant sort the files by the largest files.

    How can I do all of this in Spotlight?
    I saw a few apps (Houdahspot, PathFinder) that seem to fit the bill, but I would prefer to do this natively in OSX, or at least find a free app. I shudder to think of spending $30-$40 just to sort files.

    Thank you.
  2. GGJstudios macrumors Westmere


    May 16, 2008
    Bottom line: you can't do it in Finder. Finder doesn't give you the capability to sort search results by size or many other criteria, or to even see columns like Size in your search results. Pathfinder, as you said, can do this with ease. Finder has many limitations for those who have need of advanced file management, but it works fine for most people.
  3. Doctor Q Administrator

    Doctor Q

    Staff Member

    Sep 19, 2002
    Los Angeles
    I found a way to do it in the Finder, but it's pretty painful:
    1. Use File -> New Smart Folder in the Finder to create a smart folder window.
    2. Click + to get a rule line.
    3. Set the rule to "Name" "Ends" ".jpg"
    4. Create a new empty folder somewhere.
    5. While holding option, drag all of the results from the smart folder into the empty folder. It will copy all of those .jpg files. Don't worry that it will also cause the smart folder to update and show the duplicate copies too.
    6. Do File -> Get Info on the target folder to see the total size.
    7. Close the smart folder without saving.
    8. Erase the target folder and all those copied files!

    If you know how to use Terminal, and want to find the total size (in bytes) of all files with names ending with .jpg anywhere in your home folder, you can type these two commands:
    cd ~
    find . -name '*.jpg' -exec ls -l {} \; | awk '{sum+=$5}END{print sum}'
    I tested this in the bash shell and it got the correct total bytes. If the result is a very very large number I'm not sure if it will work or if the total might overflow. If you try it, see if the result makes sense to you.

    If you just want to see the paths and names of the files, rather than add up their sizes, type this in Terminal:
    cd ~
    find . -name '*.jpg' -exec ls {} \;
    Note: I don't recommend that people use Terminal unless they are at least somewhat familiar with it. These commands are safe but Terminal in general can be dangerous because commands you type can be quite powerful.
  4. btrotter thread starter macrumors newbie

    Aug 22, 2008
    I downloaded a free app called Find Any File, but it too wont tell me the combined size of all the files I have either highlighted or searched for.
  5. btrotter thread starter macrumors newbie

    Aug 22, 2008
    Doctor Q: You are right, that is quite painful, but I guess that would be one way of doing it.
    I am very comfortable using the terminal, but not comfortable with scripting, so I will have to stick with a gui tool.

    Thank you kindly for exploring alternatives for me!
  6. mysterytramp macrumors 65816


    Jul 17, 2008
    Open a Finder window and hit command-F

    Where the drop down menu says "Kind" is "Any", select "Any", choose "other" and enter JPEG.

    In a few moments, you'll have all the JPEGs on the hard disk.

    Select all, hit command-option-I.

    You'll get a single "Get Info" window that should tell you the number of your JPEGs as well as how much space they take totally.

  7. GGJstudios macrumors Westmere


    May 16, 2008
    .... and what about the rest of the OP's request?
  8. btrotter thread starter macrumors newbie

    Aug 22, 2008

Share This Page