-
converting powershell
Hi guys,
I have a problem. I need to convert this PowerShell program to vb.net or VbScript.
But i can't find the solution..
Could anyone help me with this?
function Remove-EmptyFolders {
[CmdletBinding()]
param ()
$delDirs = @()
$dirs = Get-ChildItem -Recurse | Where-Object { ($_.PsIsContainer) }
foreach ($dir in $dirs) {
$l = 0
$files = Get-ChildItem $dir.PSPath -Recurse | Where-Object { (!($_.PsIsContainer)) }
foreach ($file in $files) {
$l += $file.length
} # end foreach $file
if ($l -eq 0) {
Write-Verbose "$($dir.pspath | split-path -noqualifier) has no files"
$delDirs += $dir.PSPath
} # end if
else {Write-Verbose "$($dir.pspath | split-path -noqualifier) has $l bytes in files"}
} # end foreach $dir
Write-Host "The following empty directories will be removed."
Write-Host "Press 'y' to continue, any other key to stop:"
$delDirs | ForEach-Object { Split-Path $_ -NoQualifier }
if ($host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown").C haracter -eq 'y') {
$delDirs | Remove-Item -Recurse -ErrorAction SilentlyContinue
Write-Host "$($delDirs.count) directories deleted"
} # end if
} # end function
greetings
-
Have a look at these:
DirectoryInfo Class (System.IO)
My.Computer.FileSystem Object
Alternately, since deleting empty folders most likely has been done by someone before, you could search Google for the term "vb.net remove empty folders".
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks