Open vieyahn2017 opened 7 months ago
Function Get-Tree { param( [string]$directory = ".", [int]$d = 1, [switch]$f ) $absolutePath = Resolve-Path -Relative $directory Write-Host $absolutePath function Recurse-Tree { param( [string]$currentDir, [int]$currentDepth ) $indent = " " * $currentDepth $items = Get-ChildItem -Path $currentDir foreach ($item in $items) { if ($item.PSIsContainer -or $f) { Write-Host ("{0}|-- {1}" -f $indent, $item.Name) if ($item.PSIsContainer -and ($currentDepth -lt $d -or $d -eq -1)) { Recurse-Tree -currentDir $item.FullName -currentDepth ($currentDepth + 1) } } } } Recurse-Tree -currentDir $directory -currentDepth 0 } New-Alias -Name tree -Value Get-Tree
https://blog.csdn.net/qq_51352578/article/details/132701269