From 710ff06e9df3aa0ba7eeece970edec0b2d0cbc5b Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 30 Nov 2021 14:57:46 +0100 Subject: [PATCH] Add open-one-drive-folder.ps1 --- Docs/VoiceControl.md | 2 +- Scripts/close-one-drive.ps1 | 15 --------------- Scripts/open-dropbox-folder.ps1 | 14 +++++++------- Scripts/open-one-drive-folder.ps1 | 24 ++++++++++++++++++++++++ Scripts/open-one-drive.ps1 | 15 --------------- 5 files changed, 32 insertions(+), 38 deletions(-) delete mode 100755 Scripts/close-one-drive.ps1 create mode 100644 Scripts/open-one-drive-folder.ps1 delete mode 100755 Scripts/open-one-drive.ps1 diff --git a/Docs/VoiceControl.md b/Docs/VoiceControl.md index d1d9891d..4cff9c1e 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: "autostart", "desktop", "documents", "downloads", "dropbox", "home", "music", "pictures", "recycle bin", "repos", or "videos". +* replace `name` by: "Autostart", "Desktop", "Documents", "Downloads", "Dropbox", "Home", "Music", "OneDrive", "Pictures", "Recycle bin", "Repos", or "Videos". * when finished say: *Computer, close file explorer* to close the File Explorer. diff --git a/Scripts/close-one-drive.ps1 b/Scripts/close-one-drive.ps1 deleted file mode 100755 index 69188104..00000000 --- a/Scripts/close-one-drive.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -<# -.SYNOPSIS - Closes Microsoft's OneDrive -.DESCRIPTION - This script closes Microsoft's OneDrive gracefully. -.EXAMPLE - PS> ./close-one-drive -.NOTES - Author: Markus Fleschutz · License: CC0 -.LINK - https://github.com/fleschutz/PowerShell -#> - -& "$PSScriptRoot/close-program.ps1" "Microsoft OneDrive" "onedrive" "onedrive.exe" -exit 0 # success diff --git a/Scripts/open-dropbox-folder.ps1 b/Scripts/open-dropbox-folder.ps1 index 3c0601cd..c15139d1 100755 --- a/Scripts/open-dropbox-folder.ps1 +++ b/Scripts/open-dropbox-folder.ps1 @@ -1,8 +1,8 @@ <# .SYNOPSIS - Opens the user's Dropbox folder + Opens the Dropbox folder .DESCRIPTION - This script launches the File and showing the user's Dropbox folder. + This script launches the File Explorer with the user's Dropbox folder. .EXAMPLE PS> ./open-dropbox-folder .NOTES @@ -12,12 +12,12 @@ #> try { - $TargetDir = resolve-path "$HOME/Dropbox" - if (-not(test-path "$TargetDir" -pathType container)) { - throw "Dropbox folder at 📂$TargetDir doesn't exist (yet)" + $TargetDirs = resolve-path "$HOME/Dropbox*" + foreach($TargetDir in $TargetDirs) { + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success } - & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" - exit 0 # success + throw "No Dropbox folder at 📂$HOME/Dropbox" } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" exit 1 diff --git a/Scripts/open-one-drive-folder.ps1 b/Scripts/open-one-drive-folder.ps1 new file mode 100644 index 00000000..4283a020 --- /dev/null +++ b/Scripts/open-one-drive-folder.ps1 @@ -0,0 +1,24 @@ +<# +.SYNOPSIS + Opens the OneDrive folder +.DESCRIPTION + This script launches the File Explorer with the user's OneDrive folder. +.EXAMPLE + PS> ./open-one-drive-folder +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +try { + $TargetDirs = resolve-path "$HOME/OneDrive*" + foreach($TargetDir in $TargetDirs) { + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success + } + throw "No OneDrive folder at 📂$HOME/Dropbox" +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +} diff --git a/Scripts/open-one-drive.ps1 b/Scripts/open-one-drive.ps1 deleted file mode 100755 index 67d1aba7..00000000 --- a/Scripts/open-one-drive.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -<# -.SYNOPSIS - Opens Microsoft's OneDrive -.DESCRIPTION - This script launches Microsoft OneDrive with the user's OneDrive folder. -.EXAMPLE - PS> ./open-one-drive -.NOTES - Author: Markus Fleschutz · License: CC0 -.LINK - https://github.com/fleschutz/PowerShell -#> - -Start-Process "$($env:USERPROFILE)\AppData\Local\Microsoft\OneDrive\OneDrive.exe" -exit 0 # success