These scripts make it easy to remove files or folders.
REMOVE BY EXTENSION, YOU CAN EXCLUDE
Get-ChildItem -Recurse -Path 'C:\YOUR-PATH' -Exclude *.pdf , *.mp4 | Remove-Item -force -Verbose -WhatIf
DELETE FOLDERS EMPTY RECURSE
$path="C:\YOUR-PATH\*"
Get-ChildItem $path -Recurse -Force -Directory |
Sort-Object -Property FullName -Descending |
Where-Object { $($_ | Get-ChildItem -Force | Select-Object -First 1).Count -eq 0 } |
Remove-Item -Verbose -WhatIf
Parameters:
- -Verbose: to provide status updates, detailed tracking information execution by console.
- -WhatIf: for TEST before execute without changes.
- -Recurse: execute cmd recursively.
- -Exclude: for exclude folders, extensions.
Thanks for read!
Top comments (0)