0

The solution in this SE answer works but Windows keeps forgetting this setting each time I restart or move to a different folder.

Is there any way to make this setting permenant or a default?

Sort files by date modified, but folders always before files in Windows Explorer?

The goal is the following:

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

This is the solution that works well":

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.

Now the only problem is how does this make this permanent across all folders and saved between restarts.

Is there a batch file etc. that could do this? I was assuming it would be remembered across all sub-folders but apparently not.

3 Answers3

1

Following up on your comment to harrymc's answer. Apply to Folders works on a per-FolderTYpe basis, but it's only available to a subset of the defined FolderTypes. To the frustration of many, it's most notably absent from Searchesults and Libraries. The FolderTypes and their default views are difined in the Registry under: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes
You can view the comeplete list with this PowerShell code:

gci 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes' |
     select @{ N = 'ID'   ; E = { $_.PSChildName } },
            @{ N = 'Name' ; E = { $_.GetValue('CanonicalName') } } |
     Sort Name |
Out-GridView

When you execute Apply to Folders, A REG_BINARY value named for its associated FolderType is created under:
HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults This PowerShell will list the FolderTypes that have a customized default view set by Apply to Folders:

$Defaults = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults'
$FT       = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes'
( Get-Item $defaults ).Property | ForEach {
     ( gi "$FT\$_" ).GetValue( 'CanonicalName' )
}

ProcMon has revealed that the explorer.exe process only checks the ...Streams\Defaults key for the following values:

ID                                     Name
--                                     ----
{885A186E-A440-4ADA-812B-DB871B942259} Downloads
{5C4F28B5-F869-4E84-8E60-F11DB97C5CC7} Generic
{7D49D726-3C21-4F05-99AA-FDC2C9474656} Documents
{94D6DDCC-4A68-4175-A374-BD584A510B78} Music
{B3690E58-E961-423B-B687-386EBFD83239} Pictures
{5FA96407-7E77-483C-AC93-691D05850DE8} Videos
{4F01EBC5-2385-41F2-A28E-2C5C91FB56E0} StorageProviderGeneric
{DD61BD66-70E8-48DD-9655-65C5E1AAC2D1} StorageProviderDocuments
{672ECD7E-AF04-4399-875C-0290845B6247} StorageProviderMusic
{71D642A9-F2B1-42CD-AD92-EB9300C7CC0A} StorageProviderPictures
{51294DA1-D7B1-485B-9E9A-17CFFE33E187} StorageProviderVideos
{DB2A5D8F-06E6-4007-ABA6-AF877D526EA6} AccountPictures
{DE2B70EC-9BF7-4A93-BD3D-243F7881D492} Contacts
{24CCB8A6-C45A-477D-B940-3382B9225668} HomeFolder
{C4D98F09-6124-4FE0-9942-826416082DA9} UsersLibraries
{D674391B-52D9-4E07-834E-67C98610F39D} Programs
{CD0FC69B-71E2-46E5-9690-5BCD9F57AAB3} UserFiles
{0B0BA2E3-405F-415E-A6EE-CAD625207853} Searches

So to modify other FolderTypes, and avoid the undesireable, brute-force method of modifying the FolderTypes under HKLM, there are two options. Both involve creating registry entires that don't exist by default -- which means reversing the edits is a simple matter of deletion.

One option is to create GUID-named subkeys under:
HKCU\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell
and creating these is the simplest method if you only want to change the icon mode, for example, setting SearchResults to Details rather than Content.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{20338b7b-531c-4aad-8011-f5b3db2123ec}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{36011842-dccc-40fe-aa3d-6177ea401788}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{3D1D4EA2-1D8C-418a-BFF8-F18370157B55}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{4dcafe13-e6a7-4c28-be02-ca8c2126280d}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{503a4e73-1734-441a-8eab-01b3f3861156}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{59BD6DD1-5CEC-4d7e-9AD2-ECC64154418D}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{71689ac1-cc88-45d0-8a22-2943c3e7dfb3}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{7fde1a1e-8b31-49a5-93b8-6be14cfa4943}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{921C636D-9FC8-40d7-899E-0845DCD03010}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{e053a11a-dced-4515-8c4e-d51ba917517b}] "Mode"=dword:00000004

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell{ea25fbd7-3bf7-409e-b97f-3352240903f4}] "Mode"=dword:00000004

But because these entries use the same format as the individual folder views saved under HKCU\...\Bags, they don't lend themselves to modifying default columns, sortBy, or GroupBy specifications as those are rather cryptic binary values:

    Hive: HKEY_CURRENT_USER\SOFTWARE\Classes\Local
    Settings\Software\Microsoft\Windows\Shell\Bags\116\Shell

Name Property


{5F4EAB9A-6833-4F61-899D-31CF4 Rev : 2 6979D49} FFlags : 1090519041 Vid : {137E7700-3573-11CF-AE69-08002B2E1262} Mode : 4 LogicalViewMode : 1 IconSize : 16 Sort : {0, 0, 0, 0...} ColInfo : {0, 0, 0, 0...} GroupView : 4294967295 GroupByKey:FMTID : {23620678-CCD4-47C0-9963-95A8405678A3} GroupByKey:PID : 100 GroupByDirection : 1

So to modify those, it's easier to go with the other option: creating a copy of HKLM\...\FOlderTypes under HKCU. When these entries exist, they override the HKLM values.

With these copies, you can modify the various values found under the varous GUID-named TopViews, which lend thesmselves more readily to human reading/editing:

{dfbd6ba3-1846-438f-8675-b65a6bd9d418} ColumnList      : prop:0System.ItemNameDisplay;0S
                                       ystem.ItemDate;0System.ItemTypeText;0Sy
                                                         stem.Size;0System.Media.Duratio
                                       n;0System.ItemFolderPathDisplay;1System
                                                         .DateCreated;1System.DateModifi
                                       ed;1System.Search.Rank;1System.Media.Da
                                                         teEncoded;1System.Image.Dimensi
                                       ons;2System.Video.FrameWidth;2System.Vi
                                                         deo.FrameHeight
                                       LogicalViewMode : 1
                                       Name            : @shell32.dll,-34839
                                       Order           : 7
                                       QueryType       : 1
                                       SortByList      : prop:System.ItemNameDisplay

You'd be wanting to edit the SortByList values for the various TopViews, here's a rundown of their defaults:

PS C:\...\Mirror-Folder>$rp.ft | gci |
>>  ? { $_.GetValue('CanonicalName') -match 'SearchResults$' } |
>>        gci -Recurse | ? PSChildName -like '{*}' | gp |
>>              select @{ N = 'LVM'        ; E = { $_.LogicalVIewMode }},
>>                     @{ N = 'FolderTYpe' ; E = { ( Split-Path $_.PSParentPath | gp ).CanonicalName  }},
>>                     @{ N = 'ArrangeBy'  ; E = { gls $_.Name }},
>>                     SortByList |
>> ft -AutoSize -Wrap

LVM FolderTYpe ArrangeBy SortByList


1 Contacts.SearchResults Name prop:System.ItemNameDisplay;-System.Date Modified 1 Contacts.SearchResults Folder prop:System.ItemNameDisplay;-System.Date Modified 1 Contacts.SearchResults Category prop:System.Category;-System.DateModifie d 5 Documents.SearchResults Top results prop:-System.Search.Rank;-System.DateMod ified;System.ItemNameDisplay 5 Documents.SearchResults Date modified prop:-System.DateModified 5 Documents.SearchResults Tag prop:System.ItemNameDisplay;-System.Date Modified 5 Documents.SearchResults Type prop:System.ItemNameDisplay;-System.Date Modified 5 Documents.SearchResults Author prop:System.ItemNameDisplay;-System.Date Modified 5 OtherUsers.SearchResults Date modified prop:-System.DateModified 5 OtherUsers.SearchResults Top results prop:-System.Search.Rank;-System.DateMod ified;System.ItemNameDisplay 5 Pictures.SearchResults Date modified prop:-System.DateModified 3 Pictures.SearchResults Top results prop:-System.Search.Rank;-System.ItemDat e;System.ItemNameDisplay 3 Pictures.SearchResults Rating prop:-System.ItemDate;System.ItemNameDis play 3 Pictures.SearchResults Tag prop:-System.ItemDate;System.ItemNameDis play 3 Pictures.SearchResults Day prop:+System.ItemDate;System.ItemNameDis play 3 Pictures.SearchResults Month prop:-System.ItemDate;System.ItemNameDis play 5 Communications.SearchResults Top results prop:System.Contact.FileAsName;-System.M essage.DateReceived;-System.Search.Rank 5 UsersLibraries.SearchResults Date modified prop:-System.DateModified 5 UsersLibraries.SearchResults Top results prop:-System.Search.Rank;-System.DateMod ified;System.ItemNameDisplay 5 Music.SearchResults Top results prop:-System.Search.Rank;-System.DateMod ified;System.ItemNameDisplay 1 Music.SearchResults Song prop:System.Music.Artist;System.Music.Al bumTitle;System.Music.TrackNumber;System .Title 5 Music.SearchResults Genre prop:System.Music.Artist;System.Music.Al bumTitle;System.Music.TrackNumber;-Syste m.DateModified 5 Music.SearchResults Date modified prop:-System.DateModified 5 Music.SearchResults Rating prop:System.Music.Artist;System.Music.Al bumTitle;System.Music.TrackNumber 5 Music.SearchResults Artist prop:System.Music.Artist;System.Music.Al bumTitle;System.Music.TrackNumber;-Syste m.DateModified 5 Music.SearchResults Album prop:System.Music.Artist;System.Music.Al bumTitle;System.Music.TrackNumber;-Syste m.DateModified 5 Generic.SearchResults Date modified prop:-System.DateModified 5 Generic.SearchResults Top results prop:-System.Search.Rank;-System.DateMod ified;System.ItemNameDisplay 5 PublishedItems.SearchResults Top results prop:-System.Search.Rank;System.ItemName Display;-System.DateModified 5 PublishedItems.SearchResults Date modified prop:-System.Search.Rank;System.ItemName Display;-System.DateModified 5 UserFiles.SearchResults Date modified prop:-System.DateModified 5 UserFiles.SearchResults Top results prop:-System.Search.Rank;-System.DateMod ified;System.ItemNameDisplay 3 Videos.SearchResults Top results prop:-System.Search.Rank;-System.ItemDat e;System.ItemNameDisplay 3 Videos.SearchResults Year prop:+System.ItemDate;System.ItemNameDis play 5 Videos.SearchResults Date modified prop:-System.DateModified 3 Videos.SearchResults Type prop:System.ItemNameDisplay;-System.Date Modified 2 Videos.SearchResults Length prop:-System.Media.Duration 1 Videos.SearchResults Name prop:System.ItemNameDisplay

The Arrange By> options are available for SearchResults folders when the search is initiated from a Library: enter image description here

****This answer in progress...nedd some sleep...

Keith Miller
  • 10,694
  • 1
  • 20
  • 35
0

To apply the current folder's view and sort order to all folders:

  • Go to the View pane
  • Click on Options > Change folder and search options
  • Go to the View Tab
  • Click on Apply to Folders
harrymc
  • 498,455
0

The free app WinSetView will let you globally set all default folder views, including Libraries and Search results. It applies the same HKCU FolderTypes registry values that are noted in Keith Miller's answer.

LesFerch
  • 575