Keep folders at the top when Finder sorts by name
· 5 min read
Finder can put folders above files when a window is sorted by name, but the switch is off on a new Mac. Open Finder, choose Finder, Settings, click Advanced, and turn on “Keep folders on top: In windows when sorting by name”. A second checkbox does the same for the Desktop, and both apply to every window as soon as you close the settings.
Where the setting is
- Click the Desktop or any Finder window so Finder is the active app.
- Choose Finder, Settings from the menu bar. Command-comma opens the same window.
- Click Advanced.
- Under “Keep folders on top”, tick “In windows when sorting by name”.
- Tick “On Desktop” if you also want folders grouped before files on the Desktop.
There is no restart involved. A window that is already sorted by name re-sorts itself the moment you tick the box, which is a useful way to confirm it took.
On macOS versions before Ventura the same window is called Finder, Preferences, and the checkboxes are in the same place.
Why it only works when sorting by name
The checkbox says “when sorting by name” and it means it. Sort a window by Date Modified, Size or Date Added and folders go back to being mixed in with files, ordered by their own date or size. That is deliberate. If you sort by date to find what changed today, a folder from 2019 pinned to the top would defeat the point.
If you want folders kept separate in every sort order, the closer tool is grouping. In any Finder window choose View, Group By, then Kind. Folders become a group of their own with a heading, files group below them by type, and within each group you can still sort by whatever you like. It is a different look, with section headers, so try it on one folder before you commit.
Sorting by Kind on its own also puts folders together, because “Folder” is a kind, but they land wherever the alphabet places the word Folder among your other kinds rather than at the top.
Making name the default sort
Finder remembers view and sort settings per folder. The “keep folders on top” checkbox is global, but “sorted by name” is not. A window you once sorted by Date Modified stays that way, and folders in it will not float up.
To make name the starting point for folders that have no saved settings of their own:
- Open a folder and set it up the way you want. In list view, click the Name column header. In icon view, choose View, Sort By, Name.
- Choose View, Show View Options. Command-J is the shortcut.
- Check that Sort By reads Name.
- Click “Use as Defaults” at the bottom of the panel.
Folders you have already customized keep their own settings. To reset one, open it, press Command-J, and change the sort there; the choice is stored for that folder alone.
The Terminal version
The same setting exists as a preference key, which matters if you set up several Macs from a script or want to change it without clicking through Finder:
defaults write com.apple.finder _FXSortFoldersFirst -bool true
defaults write com.apple.finder _FXSortFoldersFirstOnDesktop -bool true
killall Finder
The killall Finder line restarts Finder so it reads the new value; the Desktop blinks and comes straight back with your windows intact. To undo, replace write ... -bool true with delete and the key name, then restart Finder again. What defaults write does covers what those commands change and how to record the old value first.
If Terminal is not where you want to spend the afternoon, Mainspring exposes this as a power-up called “folders on top”, alongside the other Finder settings people tend to change together (full path in the title bar, hidden files, no .DS_Store on external drives). It snapshots the previous value before flipping anything, so turning it back off is one click rather than a command you have to look up.
Two settings in the same pane worth a look
While you are in Finder Settings, Advanced, two neighbors are worth a moment.
Show all filename extensions. Off by default, which is how a folder ends up with three things called “Report” and no way to tell the PDF from the Pages document without opening each. With it on, sorting by name also lines up files with the same base name next to each other, extension after extension.
When performing a search: Search the Current Folder. The default searches the whole Mac from any window’s search field, which is rarely what you meant when you typed a word into a folder you are looking at.
Neither of these has anything to do with folder order, but they are the two questions people ask next once the folders are where they expect.
Questions
Folders are still mixed in on my Desktop. Why? Two things have to be true: the “On Desktop” checkbox is ticked, and the Desktop is actually sorted. Right-click an empty part of the Desktop, choose Sort By, and pick Name. If Sort By is set to None, icons stay where you dropped them and no ordering rule applies.
Can I put folders at the bottom instead? Not with the checkbox; it only offers the top. The workaround is Group By Kind, then sort each group as you like. Some people prefer that anyway, because a folder heading makes the split obvious.
I cannot find the checkbox at all. It arrived in macOS Sierra. On anything older, folders and files sort together with no option to separate them, apart from grouping by kind. On current versions, make sure you are in Finder, Settings, Advanced and not in a window’s View Options, which is a different panel.
Does the setting change how the Terminal lists files?
No. ls has its own ordering and ignores Finder preferences entirely.