39

I am new to Mac OS. I want to have the folders first before any other file in finder through my cocoa app.

Can anyone suggest me a way of doing this like xtraFinder, PathFinder etc apps do?

I have gone through the followings links. One way is this:

http://hints.macworld.com/article.php?story=2011072120153685 http://mygeekdaddy.net/2013/10/24/change-mavericks-finder-app-sort-order/

And the other way I got is to drag the folders to first in the spotlight (in system preferences) then sort by kind.

But in both ways I don't know how to do this programmatically. Can anyone tell me step by step how to do this through my app?

Cœur
  • 37,241
  • 25
  • 195
  • 267
user11
  • 391
  • 1
  • 3
  • 4

5 Answers5

78

OS X Sierra finally has an option for this:

  • Open Finder
  • Go to Finder Menu -> Preferences
  • Go to "Advanced" tab
  • Check the "Keep folders on top when sorting by name"

Now, When you sort by name, can see folders at top of files (like as windows)

enter image description here

Good Luck ;)

Kuba Spatny
  • 26,618
  • 9
  • 40
  • 63
Memariaan
  • 881
  • 6
  • 4
15

For Mavericks and Yosemite: From any Finder window either right-click in the window or select the icon that looks like a gear from the menu bar.

Next, select "Show View Options".

Set "Arrange by" to Name. Set "Sort by" to Kind.

enter image description here

Optionally, you can save these settings as a default.

Also note that you may need to do this for each drive and/or "top" folder.

Chris Calo
  • 7,518
  • 7
  • 48
  • 64
Rob LaRosa
  • 167
  • 1
  • 3
  • 1
    I want to do a two stage sort - by Kind + by date modified. What I really want is an option to put folders on top always, then do secondary sort from there. Xtrafinder did this but does not work on newer versions of OSX. – Kevin Mar 29 '16 at 20:45
  • 1
    The "correct" answer as of Sierra is the Finder advanced preference "Keep folders on top when sorting by name". http://stackoverflow.com/a/37889738/101869 – Chris Calo Mar 05 '17 at 02:40
  • @Kevin did you find a solution to this annoying problem? – mrchance Jan 26 '21 at 14:57
3

I pretty much like everything mac, but this windows-like feature is kinda nice to your eyes. thanks

Memariaan solutions also works in 10.14.2 Mojave but there are two selections now instead of one.

enter image description here

vknyvz
  • 653
  • 7
  • 12
0

According to crunchgeek (And validated myself on Mac OSX 10.9.5)

cd /System/Library/CoreServices/Finder.app/Contents/Resources/English.lproj/ 
sudo plutil -convert xml1 InfoPlist.strings
sudo nano InfoPlist.strings

Now change <string>Folder</string> by adding a space to get <string> Folder</string>. Finally "encode [the] file back into binary format."

sudo plutil -convert binary1 InfoPlist.strings

Now open Finder View Options via Command+J and select Kind under "Sort by".

reubano
  • 5,087
  • 1
  • 42
  • 41
  • I get an "Operation not permitted" error in El Capitan. – Halil Jun 28 '16 at 20:15
  • Did you have to restart/quit Finder, or OS X as well? Also how can one quit finder? Don't see an option to fully quit. @Halil you probably entered "nano InfoPlist.strings" instead of "sudo nano InfoPlist.strings"; the terminal text editor has to be opened as an administrator. – Luke Davis Oct 24 '16 at 22:49
  • You can't quit finder, only restart it. I don't think I had to restart finder, but the changes should take effect if you do. – reubano Oct 31 '16 at 09:42
-1

To make the folders come first in finder, change the order of data categories in spotlight.

Hit Command plus spacebar and then type spotl. That opens spotlight preferences. You will see all the data categories you have checked, or are checked by default. Simply drag "folders" to the top of the list. You can also arrange all the data categories in the order you want. So when you are looking in Finder and opt to arrange by "kind" the folder show up first together with any other changes in the order that you made.

Thanks to David Pogue's OSX Yosemite, the missing manual, Page 132.