Files
PowerShell/scripts/cd-sync.ps1
Markus Fleschutz 5b8766d233 Updated cd-sync.ps1
2025-07-08 16:04:26 +02:00

29 lines
818 B
PowerShell
Executable File

<#
.SYNOPSIS
Sets the working directory to the user's Sync folder
.DESCRIPTION
This PowerShell script changes the current working directory to the user's Syncthing folder.
.EXAMPLE
PS> ./cd-sync.ps1
📂C:\Users\Markus\Sync with 2 files and 0 folders entered.
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if (-not(Test-Path "~/Sync" -pathType container)) {
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 with $($files.Count) files and $($folders.Count) folders entered."
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0])"
exit 1
}