Search
 
SCRIPT & CODE EXAMPLE
 

BASIC

powershell how to removve only empty direcoties

# A script block (anonymous function) that will remove empty folders
# under a root folder, using tail-recursion to ensure that it only
# walks the folder tree once. -Force is used to be able to process
# hidden files/folders as well.
$tailRecursion = {
    param(
        $Path
    )
    foreach ($childDirectory in Get-ChildItem -Force -LiteralPath $Path -Directory) {
        & $tailRecursion -Path $childDirectory.FullName
    }
    $currentChildren = Get-ChildItem -Force -LiteralPath $Path
    $isEmpty = $currentChildren -eq $null
    if ($isEmpty) {
        Write-Verbose "Removing empty folder at path '${Path}'." -Verbose
        Remove-Item -Force -LiteralPath $Path
    }
}
Comment

PREVIOUS NEXT
Code Example
Basic :: basic authentication in REST api Dajngo 
Basic :: how to capture link cefsharp 
Basic :: xolo themeforest 
Basic :: robocopy sync one way 
Basic :: basic murmur hash function 
Basic :: shortcut to rename the file on lenovo s340 
Elixir :: elixir string concatination 
Elixir :: what is elixir language 
Elixir :: phoenix query get first record 
Elixir :: elixir anonymous function 
Elixir :: elixir enum map_every 
Scala :: scala string to lower case 
Scala :: scala predicate 
Scala :: get last index of list scala 
Actionscript :: octahedron 
Excel :: google sheets sort column by item frequency 
Excel :: select full column in excel 
Perl :: perl sigils 
Pascal :: pascal input number 
Pascal :: Pascal (fpc 3.0.4) sample 
Powershell :: How to save Jira attachments using powershell 
Clojure :: ex: Clojure define expected time 
Assembly :: Cannot open self /usr/local/bin/docker-compose 
Assembly :: glsl uniform struct 
Assembly :: get public ssh key 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: filesaver.min.js cdn 
Javascript :: ajax cdn 
Javascript :: How to get the browser to navigate to a URL in JavaScript 
Javascript :: how to find number in string js 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =