mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-20 03:37:56 +02:00
Added cd-desktop.ps1
This commit is contained in:
parent
19b01060e5
commit
3478ceb585
@ -5,7 +5,7 @@
|
|||||||
This PowerShell script changes the working directory to the user's desktop folder.
|
This PowerShell script changes the working directory to the user's desktop folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-desktop.ps1
|
PS> ./cd-desktop.ps1
|
||||||
📂/home/Markus/Desktop (has 3 files and 0 folders)
|
📂/home/Markus/Desktop with 3 files and 0 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -21,13 +21,13 @@ try {
|
|||||||
} else {
|
} else {
|
||||||
$path = [Environment]::GetFolderPath('DesktopDirectory')
|
$path = [Environment]::GetFolderPath('DesktopDirectory')
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) {
|
||||||
throw "No desktop folder at $path yet"
|
throw "Desktop folder at $path does not exist yet"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path entered (has $($files.Count) files and $($folders.Count) folders)"
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ Error: $($Error[0])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user