View Single Post
Old 07-26-2007   #2 (permalink)
RichS


 
 

RE: Pecursive Delete Implementation in PowerShell

You could try something like this

$fso = New-Object -com "Scripting.FileSystemObject"
$folder = $fso.GetFolder("C:\Test\")

foreach ($subfolder in $folder.SubFolders)
{
If ($subfolder.Name -like "*.svn")
{

remove-item $subfolder.Path -Verbose


}


}
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"S. A. Gnezdov" wrote:

> I want to replace VBScript with PowerShell implementation. Here is VBScript
> content:
>
> ' Deletes all .svn folders recursively
> '
> ' To delete all .svn directories in current directory recursively execute
> command:
> ' cscript del-svn-recursively.vbs
>
> Set FSO = CreateObject("Scripting.FileSystemObject")
> ShowSubfolders FSO.GetFolder(".")
>
> Sub ShowSubFolders(Folder)
> For Each eachFolder in Folder.SubFolders
> ' FSO.DeleteFolder(eachFolder)
> if eachFolder.Name = ".svn" then
> WScript.Echo eachFolder.Path
> FSO.DeleteFolder eachFolder.Path, True
> else
> ShowSubFolders eachFolder
> end if
> Next
> End Sub
>

My System SpecsSystem Spec