Created
August 28, 2023 23:42
-
-
Save umer936/f0bf66b80fd9a05aa35932237cb8fa99 to your computer and use it in GitHub Desktop.
Powershell empty/duplicate finder/remover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls *.* -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } | % { $_.group | select -skip 1 } | del | |
# https://n3wjack.net/2015/04/06/find-and-delete-duplicate-files-with-just-powershell/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tdc="C:\a\c\d" | |
do { | |
$dirs = gci $tdc -directory -recurse | Where { (gci $_.fullName -Force).count -eq 0 } | select -expandproperty FullName | |
$dirs | Foreach-Object { Remove-Item $_ } | |
} while ($dirs.count -gt 0) | |
# https://stackoverflow.com/questions/28631419/how-to-recursively-remove-all-empty-folders-in-powershell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment