Updated cd-sync.ps1

This commit is contained in:
Markus Fleschutz
2025-07-08 16:04:26 +02:00
parent af7642be7f
commit 5b8766d233

View File

@ -2,10 +2,10 @@
.SYNOPSIS
Sets the working directory to the user's Sync folder
.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
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
https://github.com/fleschutz/PowerShell
.NOTES
@ -14,15 +14,15 @@
try {
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"
Set-Location "$path"
$files = 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
} catch {
"⚠️ Error: $($Error[0])"
"⚠️ ERROR: $($Error[0])"
exit 1
}