mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-19 00:46:30 +02:00
Updated the manuals
This commit is contained in:
65
docs/cd-sync.md
Normal file
65
docs/cd-sync.md
Normal file
@@ -0,0 +1,65 @@
|
||||
The *cd-sync.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the user's Syncthing folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/Repos/PowerShell/scripts/cd-sync.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-sync.ps1
|
||||
📂C:\Users\Markus\Sync entered (has 2 files and 0 folders)
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.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.
|
||||
.EXAMPLE
|
||||
PS> ./cd-sync.ps1
|
||||
📂C:\Users\Markus\Sync entered (has 2 files and 0 folders)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
if (-not(Test-Path "~/Sync" -pathType container)) {
|
||||
throw "No 'Sync' folder in your home directory - is Syncthing installed?"
|
||||
}
|
||||
$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)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
Reference in New Issue
Block a user