Disable-DownloadsGrouping.ps1

<#PSScriptInfo
 
.VERSION 1.0.0
 
.GUID 9f8b3c2a-1d4e-5f6a-7b8c-9d0e1f2a3b4c
 
.AUTHOR D-Ogi
 
.COMPANYNAME
 
.COPYRIGHT (c) 2025 D-Ogi. MIT License.
 
.TAGS Windows Downloads Folder Grouping Explorer Registry Shell
 
.LICENSEURI https://github.com/D-Ogi/disable-downloads-grouping/blob/master/LICENSE
 
.PROJECTURI https://github.com/D-Ogi/disable-downloads-grouping
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
Initial release. Disables default "Group by Date" view in Windows Downloads folder.
 
.PRIVATEDATA
 
#>


<#
.SYNOPSIS
    Disables the default "Group by Date" view in Windows Explorer's Downloads folder.
 
.DESCRIPTION
    Windows 10/11 enables grouping by date in the Downloads folder by default.
    This script modifies the Windows Shell Bags registry entries to disable grouping
    for all Downloads folder views.
 
.EXAMPLE
    .\Disable-DownloadsGrouping.ps1
 
.EXAMPLE
    .\Disable-DownloadsGrouping.ps1 -NoRestartExplorer
 
.PARAMETER NoRestartExplorer
    If specified, Explorer will not be restarted after applying changes.
    You will need to restart Explorer manually or log out/in for changes to take effect.
 
.NOTES
    Author: https://github.com/D-Ogi
    Tested on: Windows 10, Windows 11
    The script modifies HKCU registry keys only (no admin rights required).
#>


[CmdletBinding()]
param(
    [switch]$NoRestartExplorer
)

$ErrorActionPreference = 'SilentlyContinue'

Write-Host "Disable Downloads Folder Grouping" -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""

# Registry paths
$bagsPath = 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags'
$allFoldersPath = 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell'
$downloadsTypeGuid = '{885a186e-a440-4ada-812b-db871b942259}'

# 1. Set default for Downloads folder type
Write-Host "[1/3] Setting default view for Downloads folder type..." -ForegroundColor Yellow

$downloadsTypePath = Join-Path $allFoldersPath $downloadsTypeGuid
if (-not (Test-Path $downloadsTypePath)) {
    New-Item -Path $downloadsTypePath -Force | Out-Null
}

Set-ItemProperty -Path $downloadsTypePath -Name 'GroupView' -Value 0 -Type DWord
Write-Host " Default GroupView set to 0 (disabled)" -ForegroundColor Green

# 2. Find and fix all existing Downloads folder bags
Write-Host "[2/3] Scanning existing folder view cache..." -ForegroundColor Yellow

$bags = Get-ChildItem $bagsPath -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -ne 'AllFolders' }
$modifiedCount = 0

foreach ($bag in $bags) {
    $shellSubPath = Join-Path $bag.PSPath 'Shell'
    if (Test-Path $shellSubPath) {
        $viewKeys = Get-ChildItem $shellSubPath -ErrorAction SilentlyContinue
        foreach ($viewKey in $viewKeys) {
            $props = Get-ItemProperty $viewKey.PSPath -ErrorAction SilentlyContinue

            $isDownloads = ($props.SniffedFolderType -eq 'Downloads') -or
                           ($viewKey.PSChildName -eq $downloadsTypeGuid)

            if ($isDownloads) {
                # Remove grouping-related properties
                Remove-ItemProperty -Path $viewKey.PSPath -Name 'GroupView' -ErrorAction SilentlyContinue
                Remove-ItemProperty -Path $viewKey.PSPath -Name 'GroupByKey:FMTID' -ErrorAction SilentlyContinue
                Remove-ItemProperty -Path $viewKey.PSPath -Name 'GroupByKey:PID' -ErrorAction SilentlyContinue
                Remove-ItemProperty -Path $viewKey.PSPath -Name 'GroupByDirection' -ErrorAction SilentlyContinue

                # Set GroupView to 0
                New-ItemProperty -Path $viewKey.PSPath -Name 'GroupView' -Value 0 -PropertyType DWord -Force | Out-Null
                $modifiedCount++
            }
        }
    }
}

Write-Host " Modified $modifiedCount cached folder view(s)" -ForegroundColor Green

# 3. Restart Explorer
Write-Host "[3/3] Applying changes..." -ForegroundColor Yellow

if ($NoRestartExplorer) {
    Write-Host " Skipping Explorer restart (use -NoRestartExplorer was specified)" -ForegroundColor DarkYellow
    Write-Host " Please restart Explorer manually or log out/in for changes to take effect." -ForegroundColor DarkYellow
} else {
    Write-Host " Restarting Explorer..." -ForegroundColor Yellow
    Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue
    Start-Sleep -Seconds 2
    Start-Process explorer
    Write-Host " Explorer restarted" -ForegroundColor Green
}

Write-Host ""
Write-Host "Done! Grouping has been disabled for the Downloads folder." -ForegroundColor Cyan