mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-01 06:04:41 +02:00
Update cd-trash.ps1 and cd-recycle-bin.ps1
This commit is contained in:
parent
3d64a05c57
commit
60c1004a40
@ -1,6 +1,6 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the user's recycle bin folder
|
Sets the working directory to the recycle bin folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's recycle bin folder.
|
This PowerShell script changes the working directory to the user's recycle bin folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
@ -20,13 +20,13 @@ function GetCurrentUserSID { [CmdletBinding()] param()
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$Path = "$HOME/.local/share/Trash/"
|
$path = "$HOME/.local/share/Trash/"
|
||||||
} else {
|
} else {
|
||||||
$Path = "C:\$Recycle.Bin\" + "$(GetCurrentUserSID)"
|
$path = "C:\`$Recycle.Bin\$(GetCurrentUserSID)"
|
||||||
}
|
}
|
||||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Recycle bin folder at 📂$Path doesn't exist (yet)" }
|
if (-not(Test-Path "$path" -pathType container)) { throw "Recycle bin folder at 📂$path doesn't exist (yet)" }
|
||||||
Set-Location "$Path"
|
Set-Location "$path"
|
||||||
"📂$Path"
|
"📂$path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the user's trash folder
|
Sets the working directory to the trash folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's trash folder.
|
This PowerShell script changes the working directory to the user's trash folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
@ -20,13 +20,13 @@ function GetCurrentUserSID { [CmdletBinding()] param()
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$Path = "$HOME/.local/share/Trash/"
|
$path = "$HOME/.local/share/Trash/"
|
||||||
} else {
|
} else {
|
||||||
$Path = "C:\$Recycle.Bin\" + "$(GetCurrentUserSID)"
|
$path = "C:\`$Recycle.Bin\$(GetCurrentUserSID)"
|
||||||
}
|
}
|
||||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Trash folder at 📂$Path doesn't exist (yet)" }
|
if (-not(Test-Path "$path" -pathType container)) { throw "Trash folder at 📂$path doesn't exist (yet)" }
|
||||||
Set-Location "$Path"
|
Set-Location "$path"
|
||||||
"📂$Path"
|
"📂$path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user