Skip to content

Commit d428dde

Browse files
committed
Add generated .reg file
1 parent 4e27d89 commit d428dde

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Windows Registry Editor Version 5.00
2+
3+
[HKEY_CLASSES_ROOT\Folder\shell\removeemptyfolders]
4+
@="Remove Empty Folders"
5+
"Icon" = "%SystemRoot%\\system32\\shell32.dll,-16806"
6+
7+
[HKEY_CLASSES_ROOT\Folder\shell\removeemptyfolders\command]
8+
@="powershell.exe -ExecutionPolicy Bypass -NoExit -windowstyle normal -Command \"try { Set-Location $pwd.Path; Set-Location -LiteralPath '%V'; function IsFolderEmpty { param ( [string]$folderPath ); $allItems = Get-ChildItem -Path $folderPath -Force; $fileItems = $allItems | Where-Object { -not $_.PSIsContainer }; $directoryItems = $allItems | Where-Object { $_.PSIsContainer }; if ($fileItems.Count -eq 0 -and $directoryItems.Count -eq 0) { return $true; } elseif ($fileItems.Count -eq 1 -and $fileItems[0].Name -eq 'desktop.ini' -and $directoryItems.Count -eq 0) { return $true; } else { return $false; } } $directories = Get-ChildItem -Path . -Recurse -Directory -Force | Sort-Object { $_.FullName.Split('\\').Count } -Descending; $index = 1; foreach ($dir in $directories) { if (IsFolderEmpty $dir.FullName) { Write-Host ($index.ToString() + '/' + $directories.Count.ToString() + ' - Removing: ' + $dir.FullName); Remove-Item $dir.FullName -Force -Recurse -Confirm:$false; } $index++; }}catch { Write-Host 'An error occured while removing empty folders recursively.' -ForegroundColor Red;}Write-Host 'Press any key to exit...';$Host.UI.RawUI.ReadKey('NoEcho, IncludeKeyDown') | OUT-NULL;$Host.UI.RawUI.FlushInputbuffer();exit;\""

0 commit comments

Comments
 (0)