diff --git a/Data/scripts.csv b/Data/scripts.csv index 7dbc93a9..5a9beb93 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -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 diff --git a/README.md b/README.md index c7198523..ebed4014 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Scripts/visualize-dir-tree.ps1 b/Scripts/visualize-dir-tree.ps1 new file mode 100755 index 00000000..5cd5689b --- /dev/null +++ b/Scripts/visualize-dir-tree.ps1 @@ -0,0 +1,40 @@ +#!/snap/bin/powershell +<# +.SYNTAX ./visualize-dir-tree.ps1 [] +.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 +}