Created
December 14, 2018 20:03
-
-
Save PadreSVK/3106457d2a8209eea6547b7c23964bbc to your computer and use it in GitHub Desktop.
PS script for create dirt tree rows for my semestral thesis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CreateDirtTree($folderRoot, $level) | |
{ | |
if(-not $(Test-Path $folderRoot)) | |
{ | |
Write-Error "Path do not exist" | |
return | |
} | |
if(-not $level){ | |
$level = 1 | |
} | |
$items = New-Object System.Collections.ArrayList; | |
$childItems = ls -Path $folderRoot | |
foreach ($item in $childItems) { | |
$size = [math]::Round($($item.length/1KB)) | |
if($size -eq 0){ | |
$size = 1 | |
} | |
if($item -is [System.IO.DirectoryInfo]){ | |
$items += ("`t" * $($level-1)) + ".$level "+ $item.Name + "." | |
$dirItems = CreateDirtTree -folderRoot $item.FullName -level $($level + 1) | |
$dirItems | %{ $items += $_ } | |
} | |
else{ | |
$items += ("`t" * $level) + ".$level "+ $item.Name +".\DTcomment{" + $size + " KB}." | |
} | |
} | |
return $items | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment