diff --git a/scripts/cd-crashdumps.ps1 b/scripts/cd-crashdumps.ps1 index eae4441c..b9734e34 100755 --- a/scripts/cd-crashdumps.ps1 +++ b/scripts/cd-crashdumps.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the crash dumps directory (Windows only). Whenever a software crashes and crash dumps are enabled(!) a crash dump file is written. This file helps to identify the reason for the crash. .EXAMPLE PS> ./cd-crashdumps - 📂C:\Users\Markus\AppData\Local\CrashDumps + 📂C:\Users\Markus\AppData\Local\CrashDumps entered (has 3 files and 0 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -21,7 +21,9 @@ try { $path += "\AppData\Local\CrashDumps" if (!(Test-Path "$path" -pathType container)) { throw "Crashdumps directory at $path doesn't exist (yet)" } Set-Location "$Path" - "📂$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 in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/scripts/cd-docs.ps1 b/scripts/cd-docs.ps1 index acea329e..efbdab17 100755 --- a/scripts/cd-docs.ps1 +++ b/scripts/cd-docs.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the documents folder. .EXAMPLE PS> ./cd-docs - 📂C:\Users\Markus\Documents + 📂C:\Users\Markus\Documents entered (has 3 files and 0 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -22,7 +22,9 @@ try { throw "Documents folder at 📂$path doesn't exist (yet)" } Set-Location "$path" - "📂$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 in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/scripts/cd-downloads.ps1 b/scripts/cd-downloads.ps1 index cd2ec760..bb697e3c 100755 --- a/scripts/cd-downloads.ps1 +++ b/scripts/cd-downloads.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the user's downloads folder. .EXAMPLE PS> ./cd-downloads - 📂C:\Users\Markus\Downloads + 📂C:\Users\Markus\Downloads entered (has 0 files and 0 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -24,7 +24,7 @@ try { Set-Location "$path" $files = Get-ChildItem $path -attributes !Directory $folders = Get-ChildItem $path -attributes Directory - "📂$path (has $($files.Count) files and $($folders.Count) folders)" + "📂$path entered (has $($files.Count) files and $($folders.Count) folders)" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/scripts/cd-home.ps1 b/scripts/cd-home.ps1 index 3c047578..18a764b3 100755 --- a/scripts/cd-home.ps1 +++ b/scripts/cd-home.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the user's home directory. .EXAMPLE PS> ./cd-home.ps1 - 📂C:\Users\Markus + 📂C:\Users\Markus entered (has 4 files and 7 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -16,7 +16,9 @@ try { $path = Resolve-Path "~" if (-not(Test-Path "$path" -pathType container)) { throw "Home folder at $path doesn't exist (yet)" } Set-Location "$path" - "📂$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 in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/scripts/cd-music.ps1 b/scripts/cd-music.ps1 index daa69fc9..6760f744 100755 --- a/scripts/cd-music.ps1 +++ b/scripts/cd-music.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the user's music folder. .EXAMPLE PS> ./cd-music - 📂C:\Users\Markus\Music + 📂C:\Users\Markus\Music entered (has 0 files and 3 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -18,12 +18,14 @@ try { } else { $path = [Environment]::GetFolderPath('MyMusic') } - if (Test-Path "$path" -pathType container) { - Set-Location "$path" - "📂$path" - exit 0 # success + if (-not(Test-Path "$path" -pathType container)) { + throw "User's music folder at 📂$path doesn't exist (yet)" } - throw "User's music folder at 📂$path doesn't exist (yet)" + 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 in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 diff --git a/scripts/cd-pics.ps1 b/scripts/cd-pics.ps1 index b1ebbb1d..1ce3959e 100755 --- a/scripts/cd-pics.ps1 +++ b/scripts/cd-pics.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the user's pictures folder. .EXAMPLE PS> ./cd-pics - 📂C:\Users\Markus\Pictures + 📂C:\Users\Markus\Pictures entered (has 7 files and 0 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -20,7 +20,9 @@ try { } if (-not(Test-Path "$path" -pathType container)) { throw "Pictures folder at 📂$path doesn't exist (yet)" } Set-Location "$path" - "📂$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 in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/scripts/cd-root.ps1 b/scripts/cd-root.ps1 index 2dab1d93..db402b47 100755 --- a/scripts/cd-root.ps1 +++ b/scripts/cd-root.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the current working directory to the root directory (C:\ on Windows). .EXAMPLE PS> ./cd-root - 📂C:\ + 📂C:\ entered (has 0 files and 7 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -15,7 +15,9 @@ try { if ($IsLinux) { $path = "/" } else { $path = "C:\" } Set-Location "$path" - "📂$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 in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/scripts/cd-screenshots.ps1 b/scripts/cd-screenshots.ps1 index ff9463c0..8bd1f885 100755 --- a/scripts/cd-screenshots.ps1 +++ b/scripts/cd-screenshots.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the user's screenshots folder. .EXAMPLE PS> ./cd-screenshots - 📂C:\Users\Markus\Pictures\Screenshots + 📂C:\Users\Markus\Pictures\Screenshots (has 7 files and 0 folders) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -28,7 +28,9 @@ function GetScreenshotsFolder { try { $path = GetScreenshotsFolder Set-Location "$path" - "📂$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 in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"