How would one go about deleting all subversion files from directory using Powershell?
+1
A:
How about using SVN Export to get a clean checkout without .svn directories?
Edit
You might want to look at the answer here:
Sofahamster
2010-02-05 20:33:04
Cannot do that, this is code that is from other machine, it's a mess.
epitka
2010-02-05 20:36:05
+5
A:
If you really do want to just delete the .svn directories, this could help:
gci c:\yourdirectory -include .svn -Recurse -Force |
Remove-Item -Recurse -Force
Edit:
Added -Force
param to gci
to list hidden directories and shortened the code.
Keith is right that it you need to avoid deleting files with .svn extension, you should filter the items using ?
.
stej
2010-02-05 20:49:07
+3
A:
Assuming you don't want to delete any files that might also have .svn extension:
Get-ChildItem $path -r *.svn -force | Where {$_.PSIsContainer} |
Remove-Item -r -force
Keith Hill
2010-02-05 22:24:36
Yes, good catch :) However, I don't assume there is some file with this extension.
stej
2010-02-05 22:46:55
Keith Hill
2010-02-05 23:09:47
BTW I look forward to the day when you don't need `Where {$_.PSIsContainer}` and all you have to do is `gci . -r -containerOnly`. I have my Get-ChildItem proxied to work this way but I can't count on other folks having it. :-(
Keith Hill
2010-02-05 23:13:14
Have you added a suggestion about `-containerOnly` to connect? I would vote for sure.
stej
2010-02-05 23:17:20
I'd lose the wildcard on the pattern and just do ".svn" - otherwise you'll get folders that end with .svn
Duncan Smart
2010-02-05 23:20:57
Stej, yes vote on it here: https://connect.microsoft.com/PowerShell/feedback/details/308796/add-enumeration-parameter-to-get-childitem-cmdlet-to-specify-container-non-container-both
Keith Hill
2010-02-05 23:35:47
Ah, so the directories aren't named like foo.svn, they are literally called ".svn"? How about files? Are there files called just ".svn" or do they have names like "foo.svn"?
Keith Hill
2010-02-05 23:49:44