I use subversion as my source code repository and it generates a svn folder. There are times where I would just like to remove all svn folders and files attached to this. Here is a simple one liner in powershell to do just that:
gci 'C:\_DevCode\CustomApps' -include _svn -recurse -force | foreach ($_) { del $_.fullname -recurse -force -whatif}
Three things:
- -whatif will do the simulation, so please remove when you are reay to run
- My folders for svn were setup as _svn while the default is actually .svn, so you may need to modify that
- -force will make sure to get rid of hidden files
You can also use this same code for example to search your machine and get rid of thumbs.db!
gci 'C:\' -include thumbs.db -recurse -force | foreach ($_) { del $_.fullname -recurse -force -whatif}
Joe,
ReplyDeleteNice trick..
Can I ask why you didn't just use pipe the folders to Remove-Item?
Like..
Get-ChildItem 'C:\_DevCode\CustomApps' -include _svn -recurse -force | Remove-Item -Recurse -Force
And I forgot the -whatif on the end as well.. :)
ReplyDeleteActually, your approach is much nicer! Thanks Steve!
ReplyDelete