mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Updated cd-sync.ps1
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user