78

I can sort files and directories in Windows Explorer by date modified. I always let recent files display first. But when I sort by date modified, directories are always displayed after the files.

Is it possible to sort files by date modified, but display directories before files?

Marcus Mangelsdorf
  • 1,207
  • 2
  • 12
  • 19
user45326
  • 2,003
  • 5
  • 29
  • 34

8 Answers8

154

First, put the directory into “Details” view mode (if it isn’t already) so you have column headings.

If you click on the “Date Modified” heading, which will sort by Date Modified (descending), and then Shift+click on “Name”, it should remain sorted by Date Modified (descending), but with the folders at the top.

Note: This is observed as not working while the “preview pane” is enabled (Windows 7).  Simply disable the preview pane temporarily with Alt+P before sorting.  The preview pane can then be re-enabled and the sort method will remain.

To revert this, just click on whatever column you want to sort by.

Once you have the sort order that you want, you can switch into one of the other view modes (e.g., “Icons”, “List” or “Tiles”), and the presentation will retain the sort order that you specified.

sHr0oMaN
  • 1,691
  • 2
  • 10
  • 5
  • 13
    This actually works (Tested on Win8.1). This is the only real solution I've seen that doesn't create other issues. – Bort Nov 29 '14 at 19:56
  • 3
    Works on Win7. Hate my company for making me work on Windows. – AlikElzin-kilaka Apr 28 '15 at 05:07
  • 1
    Awesome! I never knew this. I don't understand why people still say bad things about windows what else anyone need from an OS when MS already taking care of features at such fine level – dbza May 09 '15 at 00:46
  • 3
    Worked perfectly on Windows 7, this is the best solution to this issue. – Jake Bathman Aug 04 '15 at 14:43
  • 12
    Worked for me on Windows 10 as well. – jenovachild Aug 10 '15 at 05:08
  • 1
    Works, but at least in Windows 10, not if the folder is customized to be for anything but General Items. You set this in the Properties for the folder itself. – narration_sd Sep 02 '15 at 08:11
  • 6
    Thanks a lot for this. I know I'm a little late, but what is happening when you Shift Click on Name? Is that the secondary sort or something? – charlie Mar 15 '16 at 00:47
  • 2
    Thx, took me a minute before I realised I first had to show the folder as list to get headers :P – Edwin Stoteler Jun 15 '16 at 17:40
  • 2
    Tried this today on windows 10 and it also works when the preview pane is visible. – exhuma Apr 22 '17 at 07:37
  • 1
    Answering my own question: to sort by "Date modified" AND make sure it is by descending order, I went to Details mode, clicked "Date modified" enough times to get to the sort order I wanted, the shift-clicked Type as a secondary sort. Then, it's possible to go to List mode with the settings intact. – Agamemnus Jan 03 '18 at 09:33
  • 2
    Unfortunately, this didn't work for me on Win8.1 – Georgy Mar 07 '18 at 10:15
  • 3
    OMG... I am so overwhelmed by this answer that I almost cried – iAmLearning Nov 15 '19 at 16:22
  • 1
    and foolish me back again to upvote as forgot to upvote and closed the tab.... – iAmLearning Nov 15 '19 at 16:24
  • 4
    So this works but windows keeps "forgetting" this in subfolders or on restart etc. Is there a way to make this permanent default for all folders? – curious_cat Sep 10 '20 at 08:05
  • 2
    i really wonder how the OP figured this out :) – tinker Jan 19 '22 at 10:24
  • I used this method to help me by adding "Filename" as a sort option and Shit + click on "Name" to get a folder named "zzNotes" to be at the bottom of a list of files and folders I have named in this manner "2021.12.31 filename." I want the most recently dated files at the top, so I have to sorted descending. However, Folders alway seem to be sorted at the top, but the method above helped me sort so they where last file (first file when I go descending order). – Dunlop Jan 21 '22 at 14:17
  • Works for me on Win10! – A.W. Dec 19 '22 at 06:11
21

Try arranging the files by Date instead of Date Modified. I always have the problem with folders appearing before my files. It seems when you arrange by date, folders are displayed at the top regardless of the direction of arrangement. When you arrange by date modified, folders are always at the bottom in descending order.

PraesesZA
  • 235
  • 2
  • 3
  • 12
    Sorry but this is wrong and misleading. Please remember that "Date" works differently than "Date modified". If you download a document from the internet today, the file could have been last "saved" a year ago. Sorting by "Date" will *likely* put that file far in the past. "Date modified" will use the date the file was copied to your computer. Thus, it's important to realize that recently downloaded files may OR MAY NOT be near the top/bottom of the list when sorted by "Data". The ACTUAL solution is posted below by "sHr0oMaN". – Bort Nov 29 '14 at 19:55
  • 1
    http://www.winhelponline.com/blog/sort-by-date-modified-folders-on-top/ – Francois May 08 '18 at 03:40
  • This is still a valuable answer, since it describes weird windows behavior. Putting Folders first when you sort by 'date', but putting files first when you sort by 'date modified'. – Tortenrandband Jun 30 '21 at 05:55
17

I've been trying to do the same (i.e. distinguish the sort for folders from files, leaving files sorted by date). A clunky solution for win7 is suggested to me by another superuser post, making use of the 'group by' capabilities. If the file attributes are displayed in explorer (e.g. view > sort by > more... > [check 'attributes']), then you can group by attribute (essentially files vs. folders) using view > group by > attributes, and sort by date modified using view > sort by > date modified. With this, I can get folders to appear at the top, and files underneath this arranged by date.

Why would I want to do this? I'm by no way pedantic in how I organize files, but I do find I end up with a large directory structure - and typically when clicking through this, I'm usually interested in getting to subfolders. When I've reached the folder I want however, I usually will be wanting to access the most recently modified file. So having folders and recently modified files at the top saves scrolling.

  • 13
    Why was this accepted as the answer? Isn't OP trying to avoid the default behavior of automatically grouping files and folders separately during a sort? This doesn't answer the question... – Omar Jan 01 '13 at 04:09
  • 1
    You're right, this is a clunky, plus it doesn't always keep folders before files like the completely hidden answer by @sHr0oMaN – jla Aug 17 '15 at 18:08
  • 1
    This is not the answer. The answer is below at http://superuser.com/a/595669/427063. – Mark Cramer Oct 11 '16 at 14:57
  • Appreciate THIS answer, because I want to do the exact opposite of what OP wants. For certain folders I want to see the files FIRST and newest FIRST. So using the method laid out by @tryingToBeClever worked perfectly. Thanks!! – Malachi Jan 25 '23 at 15:25
4

In Windows:

dir /og-d

will sort directories first (g) then in most-recent-first (-d) order.

Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
  • 2
    I, and the OP are interested in the sorting in Windows Explorer. Your command worked, but how do I make it apply to Windows Explorer? – jla Aug 17 '15 at 17:53
  • 1
    @jla: I answered the question before the OP added the Windows Explorer qualification. – Dennis Williamson Aug 17 '15 at 19:22
3

No, unfortunately this is how Windows Explorer behaves, it always groups the folders together before files (or after, depending on the sort direction).

Many users have complained and requested the ability to interleave files and folders like some other OSes do, but it is still not an option with Windows Explorer (though some alternative Windows shells and file-managers have implemented such a function).

Synetech
  • 68,243
  • 36
  • 223
  • 356
  • I agree that it groups folders without group-by selected but pre 8.1 upgrade my folders always stayed on top no matter how I sorted. Now they only stay on top if I use a library view, otherwise they flop sides as you indicate. I'm pretty sure of this change, I nearly always sort by Date modified descending to grab the most recently built output so the change was immediately apparent and jarring to my process. – jla Aug 17 '15 at 18:02
  • Actually, if you set the directory as being "Photos" or "Video" then the folders will always be at top, regardless of sort direction. – apraetor May 11 '16 at 17:31
3

The @tryingToBeClever's answer worked for me, but with two additional steps:

  1. view > sort by > more... > [check 'Attributes']
  2. view > group by > Attributes
  3. view > sort by > Attributes
  4. view > sort by > Descending (or click on the Attributes tab)
  5. view > sort by > Date modified

I had to add steps 3 and 4, otherwise the attribute A of the files was always going first before that of the folders, i.e., D.

imriss
  • 337
  • 4
  • 9
1
  1. Open the Properties pane for the folder in question
  2. Go to the "Customize" tab
  3. Change the folder content type to "Photos"

Folders will now always be kept at the top, regardless of sort direction.

apraetor
  • 199
  • 1
  • 7
  • I prefer this approach vs having to manually sort by `date`, then shift clicking `name`. I can leave the folder and come back to the same sorting behavior. – Multinerd Aug 09 '19 at 17:02
0

TL;DR - Hold shift and click name

:Detailed Walkthrough
Start with "Detailed view"
Next, click the "Dated Modified" column header, with the arrow pointing down.
Finally, Hold shift and click the "Name" column header.

The view will now show all folders at the top, and the most recently modified files will be at the top of their group. Same with the folders, the most recent will be at the top of the folders.

You can then apply it to the defaults for all File Explorer views by going to:
Files>Change Folder and Search Options>Folder Options>View
Then click "Apply to Folders"

semtex41
  • 995
  • 2
  • 9
  • 13
  • We always appreciate the contributions from our community members! However, how is this answer really different from [this one](https://superuser.com/a/595669/650163)? – Run5k May 04 '19 at 18:00
  • Ha, your point is valid. I must have skipped the part in that answer that was the same as mine. If I had noticed it, I probably would not have posted an answer. Thanks for being polite about it though! – semtex41 May 05 '19 at 21:04