1
0
mirror of https://github.com/fleschutz/PowerShell.git synced 2025-03-26 14:26:10 +01:00

Added visualize-dir-tree.ps1

This commit is contained in:
Markus Fleschutz 2021-01-29 11:07:01 +01:00
parent 9a30e78a82
commit 463403eea1
3 changed files with 43 additions and 1 deletions

View File

@ -88,6 +88,7 @@ turn-volume-down.ps1, turns the audio volume down (-10% by default)
txt2wav.ps1, converts text into a audio .WAV file
unmute-audio.ps1, unmutes audio
update-repos.ps1, updates all Git repositories under the current directory
visualize-dir-tree.ps1, visualizes the given/current directory tree
voice-control.ps1, executes the PowerShell scripts by voice
weather.ps1, prints the current weather forecast
weather-alert.ps1, checks the current weather for critical values

1 Filename,Description
88 txt2wav.ps1, converts text into a audio .WAV file
89 unmute-audio.ps1, unmutes audio
90 update-repos.ps1, updates all Git repositories under the current directory
91 visualize-dir-tree.ps1, visualizes the given/current directory tree
92 voice-control.ps1, executes the PowerShell scripts by voice
93 weather.ps1, prints the current weather forecast
94 weather-alert.ps1, checks the current weather for critical values

View File

@ -1,7 +1,7 @@
Collection of Useful PowerShell Scripts
=======================================
This repository contains 100+ useful and cross-platform PowerShell scripts - to be used by command-line interface (CLI), for remote control (RC), by context menu, by voice control, by automation software (e.g. Jenkins), or simply to learn PowerShell.
This repository contains 110+ useful and cross-platform PowerShell scripts - to be used by command-line interface (CLI), for remote control (RC), by context menu, by voice control, by automation software (e.g. Jenkins), or simply to learn PowerShell.
List of Scripts
---------------
@ -96,6 +96,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [txt2wav.ps1](Scripts/txt2wav.ps1) - converts text into a audio .WAV file
* [unmute-audio.ps1](Scripts/unmute-audio.ps1) - unmutes audio
* [update-repos.ps1](Scripts/update-repos.ps1) - updates all Git repositories under the current directory
* [visualize-dir-tree.ps1](Scripts/visualize-dir-tree.ps1) - visualizes the given/current directory tree
* [voice-control.ps1](Scripts/voice-control.ps1) - executes the PowerShell scripts by voice
* [weather.ps1](Scripts/weather.ps1) - prints the current weather forecast
* [weather-alert.ps1](Scripts/weather-alert.ps1) - checks the current weather for critical values

40
Scripts/visualize-dir-tree.ps1 Executable file
View File

@ -0,0 +1,40 @@
#!/snap/bin/powershell
<#
.SYNTAX ./visualize-dir-tree.ps1 [<dir-tree>]
.DESCRIPTION visualizes the given/current directory tree
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$DirTree = "")
function VisualizeDirectory { param([string]$Directory, [int]$Depth)
$Depth++
$Items = get-childItem -path $Directory
foreach ($Item in $Items) {
$Filename = $Item.Name
if ($Item.Mode -eq "d----") {
for ($i = 0; $i -lt $Depth; $i++) {
write-host -nonewline "+--"
}
write-host "$Filename/"
VisualizeDirectory "$Directory\$Filename" $Depth
} else {
for ($i = 1; $i -lt $Depth; $i++) {
write-host -nonewline "| "
}
write-host "|-$Filename"
}
}
}
try {
if ($DirTree -eq "") {
$DirTree = "$PWD"
}
VisualizeDirectory $DirTree 0
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}