From 70d97b6e91ff3eabba015c85a320bff64094b989 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Mon, 29 Nov 2021 14:26:20 +0100 Subject: [PATCH] Add some open-*-folder.ps1 scripts --- Docs/VoiceControl.md | 2 +- Scripts/open-auto-start-folder.ps1 | 24 +++++++++++++++++++ Scripts/open-desktop-folder.ps1 | 24 +++++++++++++++++++ Scripts/open-documents-folder.ps1 | 24 +++++++++++++++++++ ...le-bin.ps1 => open-recycle-bin-folder.ps1} | 4 ++-- 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100755 Scripts/open-auto-start-folder.ps1 create mode 100755 Scripts/open-desktop-folder.ps1 create mode 100755 Scripts/open-documents-folder.ps1 rename Scripts/{open-recycle-bin.ps1 => open-recycle-bin-folder.ps1} (86%) diff --git a/Docs/VoiceControl.md b/Docs/VoiceControl.md index d0d3953e..b6e3b378 100644 --- a/Docs/VoiceControl.md +++ b/Docs/VoiceControl.md @@ -42,7 +42,7 @@ Computer, open `name` drive Computer, open `name` folder -------------------------- * launches the File Explorer with the given folder. -* replace `name` by: "downloads", "dropbox", "home", "music", "pictures", "repos", or "videos". +* replace `name` by: "autostart", "desktop", "documents", "downloads", "dropbox", "home", "music", "pictures", "recycle bin", "repos", or "videos". * when finished use: *Computer, close file explorer* to close the File Explorer. diff --git a/Scripts/open-auto-start-folder.ps1 b/Scripts/open-auto-start-folder.ps1 new file mode 100755 index 00000000..dfa515c5 --- /dev/null +++ b/Scripts/open-auto-start-folder.ps1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Opens the autostart folder +.DESCRIPTION + This script launches the File Explorer with the user's autostart folder. +.EXAMPLE + PS> ./open-auto-start-folder +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $TargetDir = resolve-path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Autostart folder at 📂$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +} diff --git a/Scripts/open-desktop-folder.ps1 b/Scripts/open-desktop-folder.ps1 new file mode 100755 index 00000000..1ffada4d --- /dev/null +++ b/Scripts/open-desktop-folder.ps1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Opens the desktop folder +.DESCRIPTION + This script launches the File Explorer with the user's desktop folder. +.EXAMPLE + PS> ./open-desktop-folder +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $TargetDir = resolve-path "$HOME/Desktop" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Desktop folder at 📂$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +} diff --git a/Scripts/open-documents-folder.ps1 b/Scripts/open-documents-folder.ps1 new file mode 100755 index 00000000..d2a5ba20 --- /dev/null +++ b/Scripts/open-documents-folder.ps1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Opens the documents folder +.DESCRIPTION + This script launches the File Explorer with the user's documents folder. +.EXAMPLE + PS> ./open-documents-folder +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $TargetDir = resolve-path "$HOME/Documents" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Documents folder at 📂$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +} diff --git a/Scripts/open-recycle-bin.ps1 b/Scripts/open-recycle-bin-folder.ps1 similarity index 86% rename from Scripts/open-recycle-bin.ps1 rename to Scripts/open-recycle-bin-folder.ps1 index b1106f68..154a874d 100755 --- a/Scripts/open-recycle-bin.ps1 +++ b/Scripts/open-recycle-bin-folder.ps1 @@ -1,10 +1,10 @@ <# .SYNOPSIS - Opens the user's recycle bin folder + Opens the recycle bin folder .DESCRIPTION This script launches the File Explorer with the user's recycle bin folder. .EXAMPLE - PS> ./open-recycle-bin + PS> ./open-recycle-bin-folder .NOTES Author: Markus Fleschutz · License: CC0 .LINK