Last active
September 18, 2017 10:20
-
-
Save ukcoderj/6f1e4f2d0af613587ffd2557ab3d78ed to your computer and use it in GitHub Desktop.
Remove all bin and object folders
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
Clear-Host | |
$folderToEmptyBins = "C:\Temp\ATest" | |
#short way | |
cd $folderToEmptyBins | |
get-childitem -Include "bin" -Recurse -force | Remove-Item -Force –Recurse | |
get-childitem -Include "obj" -Recurse -force | Remove-Item -Force –Recurse | |
#long way | |
#function DeleteSubFoldersWithName($folder, $name) | |
#{ | |
# foreach ($subfolder in $folder.SubFolders) | |
# { | |
# $subFolderName = $subfolder.Name | |
# "$subFolderName-$name" | |
# if($subFolderName -eq "symbolic-link-containing-folder") | |
# { | |
# "Powershell doesnt understand symbolic links. Remove via cmd" | |
# cmd /c rmdir /s /q $subfolder.Path | |
# continue | |
# } | |
# If ($subFolderName -eq $name) | |
# { | |
# remove-item $subfolder.Path -Verbose | |
# }# | |
# | |
# if($subfolder.SubFolders) | |
# { | |
# DeleteSubFoldersWithName $subfolder $name | |
# } | |
# } | |
#} | |
#$fso = New-Object -com "Scripting.FileSystemObject" | |
#$folder = $fso.GetFolder($folderToEmptyBins) | |
#DeleteSubFoldersWithName $folder "bin" | |
#DeleteSubFoldersWithName $folder "obj" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment