mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-25 06:24:14 +02:00
Updated cd-public.ps1 and cd-screenshots.ps1
This commit is contained in:
parent
de29c358db
commit
5ad6815eba
@ -1,11 +1,11 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the Public folder
|
||||
Sets the working dir to the Public folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the Public folder.
|
||||
This PowerShell script sets the current working directory to the Public folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-public
|
||||
📂C:\Users\Public entered (has 2 files and 3 subfolders)
|
||||
PS> ./cd-public.ps1
|
||||
📂C:\Users\Public with 2 files and 3 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -14,17 +14,20 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
if (-not(Test-Path "~/Public" -pathType container)) {
|
||||
throw "No 'Public' folder in your home directory yet"
|
||||
}
|
||||
$path = Resolve-Path "~/Public"
|
||||
} else {
|
||||
$path = Resolve-Path "~/../Public"
|
||||
if (-not(Test-Path "~/../Public" -pathType container)) {
|
||||
throw "No 'Public' folder yet"
|
||||
}
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "No public folder at $path"
|
||||
$path = Resolve-Path "~/../Public"
|
||||
}
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
|
@ -1,11 +1,11 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the user's screenshots folder
|
||||
Sets the working dir to the user's screenshots folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the user's screenshots folder.
|
||||
This PowerShell script sets the current working directory to the user's screenshots folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-screenshots
|
||||
📂C:\Users\Markus\Pictures\Screenshots (has 7 files and 0 folders)
|
||||
PS> ./cd-screenshots.ps1
|
||||
📂C:\Users\Markus\Pictures\Screenshots with 7 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -14,12 +14,12 @@
|
||||
|
||||
function GetScreenshotsFolder {
|
||||
if ($IsLinux) {
|
||||
if (-not(Test-Path "~/Pictures" -pathType container)) { throw "No 'Pictures' folder in your home directory yet" }
|
||||
$path = "~/Pictures"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Pictures folder at $path doesn't exist (yet)" }
|
||||
if (Test-Path "$path/Screenshots" -pathType container) { $path = "$path/Screenshots" }
|
||||
} else {
|
||||
$path = [Environment]::GetFolderPath('MyPictures')
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Pictures folder at $path doesn't exist (yet)" }
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No pictures folder at: $path" }
|
||||
if (Test-Path "$path\Screenshots" -pathType container) { $path = "$path\Screenshots" }
|
||||
}
|
||||
return $path
|
||||
@ -30,7 +30,7 @@ try {
|
||||
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])"
|
||||
|
Loading…
x
Reference in New Issue
Block a user