mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-12 22:17:17 +02:00
Updated cd-sync.ps1
This commit is contained in:
@ -2,10 +2,10 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the user's Sync folder
|
Sets the working directory to the user's Sync folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's Syncthing folder.
|
This PowerShell script changes the current working directory to the user's Syncthing folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-sync.ps1
|
PS> ./cd-sync.ps1
|
||||||
📂C:\Users\Markus\Sync entered (has 2 files and 0 folders)
|
📂C:\Users\Markus\Sync with 2 files and 0 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (-not(Test-Path "~/Sync" -pathType container)) {
|
if (-not(Test-Path "~/Sync" -pathType container)) {
|
||||||
throw "No 'Sync' folder in your home directory - is Syncthing installed?"
|
throw "Your home directory has no 'Sync' folder yet - Please install Syncthing."
|
||||||
}
|
}
|
||||||
$path = Resolve-Path "~/Sync"
|
$path = Resolve-Path "~/Sync"
|
||||||
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])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user