Change Group by Folder View in Windows 10  

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 79
    10 pro
       #10

    SpacemanSam said:
    Using a 3rd-party program (SetACL by Helge Klein), I was able to take possession of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000} and delete the GroupBy value. I added it to my ConfigureWindow.bat setup file and tested it on a fresh W10 install, and it works - the Downloads directory now opens with filenames sorted in normal alphabetical order. :)

    I'd like to do it without using any 3rd-party programs, but I haven't found anything that works yet. Powershell has Get-ACL and Set-ACL, but when I tried using them, I got permission errors. None of the samples I've found so far have worked. Considering that Helge Klein's SetACL program does work and is free to download, it may not be worth the effort to pursue this much further.

    I can post the code for you if you'd like to include it in your tutorial. What's the best way to do that?
    Great news. You can post it here if you like.
    OK. Here it is. Enjoy!

    This batch file removes the "GroupBy" value from the default Explorer template for Downloads directories. After you run it, any Downloads directories which have never been already opened in Explorer will open without grouping. It does not remove the grouping from directory windows which have been opened in Explorer already, as the current layout for each Explorer window is stored in HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags in encoded form. It also does not prevent you from enabling grouping for any Explorer window if you want to.

    Instructions:

    1 If you have not done so already, create a directory on your data drive to hold Windows setup tweaks. I called it D:\ConfigureWindows, but you can use any name you want. Just don't put it in your Downloads directory!

    2 Open Explorer and navigate to D:\ConfigureWindows. Create a new batch file here and call it RemoveGroupBy.bat. Open the file in Notepad, copy this code, paste it into Notepad and save it. Or click the "Download" button below.

    Code:
    REM RemoveGroupBy.bat
    REM Remove "Group By Date" from Downloads directories
    @TITLE %~nx0
    
    REM Do we have admin rights?
    openfiles >NUL: 2>&1 || @(ECHO; & <nul: set /p "junk=This script must be run as administrator!  Press any key to exit... " & pause >NUL: & exit /b 2)
    
    REM Make sure SetACL.exe exists
    IF EXIST "%windir%\System32\SetACL.exe" GOTO :HaveSetACL
    
    REM Which version of SetACL should we use (32 bit or 64 bit)?
    IF DEFINED ProgramFiles(x86) (
     SET "SetAcl=%~dp0SetACL (executable version)\64 bit\SetACL.exe"
    ) ELSE (
     SET "SetAcl=%~dp0SetACL (executable version)\32 bit\SetACL.exe"
    )
    
    IF NOT EXIST "%SetACL%" @(<nul: set /p junk=I can't find "%SetACL%".  Press any key to exit. & PAUSE >NUL: & EXIT /B 2)
    
    COPY /Y "%SetACL%" %windir%\System32
    SET SetAcl=
    :HaveSetACL
    
    REM Now let's get down to work!
    SET W64=
    :W64loop
    SET GBKey="HKLM\SOFTWARE%W64%\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"
    
    REG QUERY %GBKey% /V "GroupBy" >NUL: 2>&1 && (
      REM Save the permissions on GBKey, then take ownership and enable the Delete permission
      SetACL -on %GBKey% -ot reg -actn list -bckp "%TEMP%\GroupBy.txt"
      SetACL -on %GBKey% -ot reg -actn setowner -ownr "n:S-1-5-32-544"
      SetACL -on %GBKey% -ot reg -actn setprot -actn ace -ace "n:S-1-5-32-544;p:full"
    
      REG DELETE %GBKey% /V "GroupBy" /F || PAUSE
    
      REM Restore the saved permissions on GroupByKey
      SetACL -on %GBKey% -ot reg -actn restore -bckp "%TEMP%\GroupBy.txt"
      DEL "%TEMP%\GroupBy.txt"
    )
    IF NOT DEFINED W64 IF DEFINED ProgramFiles(x86) SET "W64=\WOW6432Node" & GOTO :W64loop
    SET W64=
    SET GBKey=
    
    IF /I "%~1" NEQ "NOPAUSE" PAUSE
    EXIT /B 0

    Download

    3 Open a browser window / tab and navigate to Helge Klein's website to download the EXE version of SetACL. Choose either the 32-bit or 64-bit version as appropriate. UnZip the download into your ConfigureWindows directory. Verify that "ConfigureWindows\SetACL (executable version)" contains ether the "32 bit" or "64 bit" subdirectory. (I have sometimes seen .zip files unzip into two levels instead of just one. If that happens, RemoveGroupBy.bat won't be able to find SetACL.exe.) If you plan on using this on both 32-bit and 64-bit Windows, download both versions. Be sure to keep them separate!

    4 To run this tweak immediately, right-click on RemoveGroupBy.bat and select "Run as administrator".

    5 If you want to run this tweak (and any others) automatically on any fresh install or update, create a batch file in D:\ConfigureWindows that will run all of them in one swell foop. (Suggested name: ConfigureWindows.bat.) In this file, put the following lines:
    Code:
    CALL "%~dp0RemoveGroupBy.bat" nopause || @((IF %ERRORLEVEL% EQU 1 ECHO; & <nul: set /p junk=%~dp0RemoveGroupBy.bat not found!  Press any key to exit... & PAUSE >NUL:) & EXIT /B 2)
    @TITLE %~nx0
    Of course, ConfigureWindows.bat should also contain any other tweaks you want to apply at the same time. Tenforums.com has a plethora of tweaks you'll probably want to include!

    Future enhancement: The registry key to patch is hard-coded in this batch file. If I find any others that require patching in the same way, I might modify the batch file to take the key (and maybe the value) as parameters, or perhaps make the part that does the job into a subroutine that can be called with several values for the registry key.

    Finally: This tweak only removes "GroupBy" from the template used to open new Download directories for the first time. It does not affect any directory windows that have previously been opened in Explorer. I might write a script to loop through ...\Shell\Bags and change the GroupByKey:FMTID and GroupByKey:PID values for Downloads directory windows. But that's another project - stay tuned!
    Last edited by SpacemanSam; 05 Apr 2022 at 19:31. Reason: Fixed test for 64bit OS
      My Computer


  2. Posts : 61,836
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #11

    @SpacemanSam,

    Download button added to your post for the .bat file.
      My Computers


  3. Posts : 79
    10 pro
       #12

    Shawn,
    I just found out last night that the "GroupBy" value also exists in ...\WOW6432Node. I've updated the batch file to also delete GroupBy from this branch. Please do whatever is necessary so that the Download button downloads the updated version of RemoveGroupBy.bat
      My Computer


  4. Posts : 61,836
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #13

    SpacemanSam said:
    Shawn,
    I just found out last night that the "GroupBy" value also exists in ...\WOW6432Node. I've updated the batch file to also delete GroupBy from this branch. Please do whatever is necessary so that the Download button downloads the updated version of RemoveGroupBy.bat
    Done.
      My Computers


  5. Posts : 8
    Windows 10
       #14

    Thank you for sharing this script. Did you also create a script to automated some of the Microsoft Edge settings that is protected and cannot be transfer to different? Settings such as Google search default and some settings in General section. If you do, can you share it. Thanks.

    SpacemanSam said:
    OK. Here it is. Enjoy!

    This batch file removes the "GroupBy" value from the default Explorer template for Downloads directories. After you run it, any Downloads directories which have never been already opened in Explorer will open without grouping. It does not remove the grouping from directory windows which have been opened in Explorer already, as the current layout for each Explorer window is stored in HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags in encoded form. It also does not prevent you from enabling grouping for any Explorer window if you want to.

    Instructions:

    1 If you have not done so already, create a directory on your data drive to hold Windows setup tweaks. I called it ConfigureWindows, but you can use any name you want. Just don't put it in your Downloads directory!

    2 Open Explorer and navigate to D:\ConfigureWindows. Create a new batch file here and call it RemoveGroupBy.bat. Open the file in Notepad, copy this code, paste it into Notepad and save it. Or click the "Download" button below.

    Code:
    REM RemoveGroupBy.bat
    REM Remove "Group By Date" from Downloads directories
    @TITLE %~nx0
    
    REM Do we have admin rights?
    openfiles >NUL: 2>&1 || @(ECHO; & <nul: set /p "junk=This script must be run as administrator!  Press any key to exit... " & pause >NUL: & exit /b 2)
    
    REM Make sure SetACL.exe exists
    IF EXIST "%windir%\System32\SetACL.exe" GOTO :HaveSetACL
    
    REM Which version of SetACL should we use (32 bit or 64 bit)?
    IF /I "%PROCESSOR_ARCHITECTURE%" NEQ "x86" (
     SET "SetAcl=%~dp0SetACL (executable version)\64 bit\SetACL.exe"
    ) ELSE (
     SET "SetAcl=%~dp0SetACL (executable version)\32 bit\SetACL.exe"
    )
    
    IF NOT EXIST "%SetACL%" @(<nul: set /p junk=I can't find "%SetACL%".  Press any key to exit. & PAUSE >NUL: & EXIT /B 2)
    
    COPY /Y "%SetACL%" %windir%\System32
    SET SetAcl=
    :HaveSetACL
    
    REM Now let's get down to work!
    SET W64=
    :W64loop
    SET GBKey="HKLM\SOFTWARE%W64%\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"
    
    REG QUERY %GBKey% /V "GroupBy" >NUL: 2>&1 && (
      REM Save the permissions on GBKey, then take ownership and enable the Delete permission
      SetACL -on %GBKey% -ot reg -actn list -bckp "%TEMP%\GroupBy.txt"
      SetACL -on %GBKey% -ot reg -actn setowner -ownr "n:S-1-5-32-544"
      SetACL -on %GBKey% -ot reg -actn setprot -actn ace -ace "n:S-1-5-32-544;p:full"
    
      REG DELETE %GBKey% /V "GroupBy" /F || PAUSE
    
      REM Restore the saved permissions on GroupByKey
      SetACL -on %GBKey% -ot reg -actn restore -bckp "%TEMP%\GroupBy.txt"
      DEL "%TEMP%\GroupBy.txt"
    )
    IF NOT DEFINED W64 IF /I "%PROCESSOR_ARCHITECTURE%" NEQ "x86" SET "W64=\WOW6432Node" & GOTO :W64loop
    SET W64=
    SET GBKey=
    
    IF /I "%~1" NEQ "NOPAUSE" PAUSE
    EXIT /B 0

    Download

    3 Open a browser window / tab and navigate to Helge Klein's website to download the EXE version of SetACL for 32-bit and 64-bit Windows. UnZip the download into your ConfigureWindows directory. Verify that "ConfigureWindows\SetACL (executable version)" contains "32 bit" and "64 bit" subdirectories. (I have sometimes seen .zip files unzip into two levels instead of just one. If that happens, RemoveGroupBy.bat won't be able to find SetACL.exe.)

    4 To run this tweak immediately, right-click on RemoveGroupBy.bat and select "Run as administrator".

    5 If you want to run this tweak (and any others) automatically on any fresh install or update, create a batch file in D:\ConfigureWindows that will run all of them in one swell foop. (Suggested name: ConfigureWindows.bat.) In this file, put the following lines:
    Code:
    CALL "%~dp0RemoveGroupBy.bat" nopause || @((IF %ERRORLEVEL% EQU 1 ECHO; & <nul: set /p junk=%~dp0RemoveGroupBy.bat not found!  Press any key to exit... & PAUSE >NUL:) & EXIT /B 2)
    @TITLE %~nx0
    Of course, ConfigureWindows.bat should also contain any other tweaks you want to apply at the same time. Tenforums.com has a plethora of tweaks you'll probably want to include!

    Future enhancement: The registry key to patch is hard-coded in this batch file. If I find any others that require patching in the same way, I might modify the batch file to take the key (and maybe the value) as parameters, or perhaps make the part that does the job into a subroutine that can be called with several values for the registry key.

    Finally: This tweak only removes "GroupBy" from the template used to open new Download directories for the first time. It does not affect any directory windows that have previously been opened in Explorer. I might write a script to loop through ...\Shell\Bags and change the GroupByKey:FMTID and GroupByKey:PID values for Downloads directory windows. But that's another project - stay tuned!
      My Computer


  6. Xii
    Posts : 7
    Windows 10 Home
       #15

    Is there any way to add an option to a folder and all its subfolders?


    I'm working on a texture pack, and sorting by dimensions, but every time I reorganize I have to manually go and add in dimensions for each folder since the path has changed.

    Is there a command to do this quicker?
      My Computer


  7. Posts : 79
    10 pro
       #16

    Shawn,
    Xii's post brought my attention to this tut. I looked over what I had posted 2 years ago and noticed a problem I've since fixed in my current batch files: The environment variable PROCESSOR_ARCHITECTURE is not a reliable test for 64 bit vs. 32 bit Windows. It reports the hardware architecture, not the OS version. The presence or absence of the environment variable ProgramFiles(x86) indicates whether or not the directory "%SystemDrive%\Program Files (x86)" exists, and is thus a more reliable indicator of whether the OS is 64 bit or 32 bit.
    I have updated the code in my OP to include this fix. Please do whatever is necessary so that the Download button downloads the latest version of RemoveGroupBy.bat with this fix.
      My Computer


  8. Xii
    Posts : 7
    Windows 10 Home
       #17

    SpacemanSam said:
    Shawn,
    Xii's post brought my attention to this tut. I looked over what I had posted 2 years ago and noticed a problem I've since fixed in my current batch files: The environment variable PROCESSOR_ARCHITECTURE is not a reliable test for 64 bit vs. 32 bit Windows. It reports the hardware architecture, not the OS version. The presence or absence of the environment variable ProgramFiles(x86) indicates whether or not the directory "%SystemDrive%\Program Files (x86)" exists, and is thus a more reliable indicator of whether the OS is 64 bit or 32 bit.
    I have updated the code in my OP to include this fix. Please do whatever is necessary so that the Download button downloads the latest version of RemoveGroupBy.bat with this fix.
    Hey Sam while we wait can you go over the parameters I should use to do this? (I'm assuming the default just removes it from the content menu by the name)
      My Computer


  9. Posts : 79
    10 pro
       #18

    Xii said:
    Hey Sam while we wait can you go over the parameters I should use to do this? (I'm assuming the default just removes it from the content menu by the name)
    Right. My code just removes it. I didn't provide any option to change it to something else or turn it back on.

    But I'm confused as to what you are trying to accomplish. It sounds like you are running a program which generates a bunch of texture files and you want a way to automatically name the directories where the files are stored, according to their dimensions. Is that correct?

    If you could provide some details I might be able to suggest something. Can you show what's happening now and what you'd like to happen?
      My Computer


  10. Xii
    Posts : 7
    Windows 10 Home
       #19

    SpacemanSam said:
    Right. My code just removes it. I didn't provide any option to change it to something else or turn it back on.

    But I'm confused as to what you are trying to accomplish. It sounds like you are running a program which generates a bunch of texture files and you want a way to automatically name the directories where the files are stored, according to their dimensions. Is that correct?

    If you could provide some details I might be able to suggest something. Can you show what's happening now and what you'd like to happen?
    Oh no sorry. What I'm trying to do is add the "dimensions" filter to the group by/sort by content menu by default, or to apply it to the base folder and then automatically apply to all the subfolders.

    Right now I have to go in the context menu, add it, reopen the context menu, and select it, for about 50 folders.
      My Computer


 

Tutorial Categories

Change Group by Folder View in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 09:38.
Find Us




Windows 10 Forums