Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can sort files and directories in Windows Explorer by date modified. I always let recent files display first. When I sort by date modified, directories alway displayed after files.

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

share|improve this question
    
Command line or the graphical file browser? –  grawity Jan 28 '11 at 19:00
    
possible duplicate of Windows explorer: sort by date modified –  Ƭᴇcʜιᴇ007 Aug 26 '13 at 14:57

7 Answers 7

up vote 2 down vote accepted

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.

share|improve this answer
1  
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 1 '13 at 4:09
    
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 at 18:08

If you click on the Date Modified heading, which will sort by Date Modified and then Shift + click on Name it should remain sorted by Date Modified, but with 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 again and the sort method will remain.

share|improve this answer
4  
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
    
Works on Win7. Hate my company for making me work on Windows. –  AlikElzin-kilaka Apr 28 at 5:07
    
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 9 at 0:46
    
Worked perfectly on Windows 7, this is the best solution to this issue. –  Jake B. Aug 4 at 14:43
    
Worked for me on Windows 10 as well. –  jenovachild Aug 10 at 5:08

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.

share|improve this answer
    
Awesome, thanks :) –  John Apr 18 '13 at 18:08
5  
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

Depends what are you using to display contents of directory and on which OS... but if you're using ls and Linux you can do:

ls -ltr --group-directories-first

It will display recently modified files last, but display directories at the top.

share|improve this answer

In Windows:

dir /og-d

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

share|improve this answer
    
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 at 17:53
    
@jla: I answered the question before the OP added the Windows Explorer qualification. –  Dennis Williamson Aug 17 at 19:22

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).

share|improve this answer
    
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 at 18:02

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.

share|improve this answer

protected by Community Jul 21 '13 at 5:30

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.