Add cd-temp.ps1 and open-temporary-folder.ps1

This commit is contained in:
Markus Fleschutz 2021-12-09 09:27:10 +01:00
parent 6d6a49b8a1
commit dedaad01bf
3 changed files with 51 additions and 1 deletions

View File

@ -46,7 +46,7 @@ When finished say: "Computer, close file explorer" to close the File Explorer.
`Computer, open` [name] `folder`
--------------------------------
Launches the File Explorer with the given folder - replace [name] by: `autostart`, `desktop`, `documents`, `downloads`, `Dropbox`, `home`, `music`, `OneDrive`, `pictures`, `recycle bin`, `repos`, or `videos`.
Launches the File Explorer with the given folder - replace [name] by: `autostart`, `desktop`, `documents`, `downloads`, `Dropbox`, `home`, `music`, `OneDrive`, `pictures`, `recycle bin`, `repos`, `temporary`, or `videos`.
When finished say: "Computer, close file explorer" to close the File Explorer.

26
Scripts/cd-temp.ps1 Normal file
View File

@ -0,0 +1,26 @@
<#
.SYNOPSIS
Sets the working directory to the temporary folder
.DESCRIPTION
This script changes the working directory to the temporary folder.
.EXAMPLE
PS> ./cd-temp
📂C:\Users\markus\AppData\Local\Temp
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz · License: CC0
#>
try {
$TargetDir = resolve-path "$env:TEMP"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Temporary folder at 📂$TargetDir doesn't exist (yet)"
}
set-location "$TargetDir"
"📂$TargetDir"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}

View File

@ -0,0 +1,24 @@
<#
.SYNOPSIS
Opens the temporary folder
.DESCRIPTION
This script launches the File Explorer showing the temporary folder.
.EXAMPLE
PS> ./open-temporary-folder
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
https://github.com/fleschutz/PowerShell
#>
try {
$TargetDir = resolve-path "$env:TEMP"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Temporary 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
}