mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-11 16:39:10 +01:00
Add cd-temp.ps1 and open-temporary-folder.ps1
This commit is contained in:
parent
6d6a49b8a1
commit
dedaad01bf
@ -46,7 +46,7 @@ When finished say: "Computer, close file explorer" to close the File Explorer.
|
|||||||
|
|
||||||
`Computer, open` [name] `folder`
|
`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.
|
When finished say: "Computer, close file explorer" to close the File Explorer.
|
||||||
|
|
||||||
|
26
Scripts/cd-temp.ps1
Normal file
26
Scripts/cd-temp.ps1
Normal 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
|
||||||
|
}
|
24
Scripts/open-temporary-folder.ps1
Normal file
24
Scripts/open-temporary-folder.ps1
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user