From 4027d6149d1b6feed07ab0dee34319d3a7b9f89e Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sun, 18 May 2025 11:15:42 +0200 Subject: [PATCH] Updated new-markdown-file.ps1 and new-text-file.ps1 --- scripts/new-markdown-file.ps1 | 12 +++++------- scripts/new-text-file.ps1 | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/scripts/new-markdown-file.ps1 b/scripts/new-markdown-file.ps1 index 5e744aaf..a537d114 100755 --- a/scripts/new-markdown-file.ps1 +++ b/scripts/new-markdown-file.ps1 @@ -4,26 +4,24 @@ .DESCRIPTION This PowerShell script creates a new Markdown file from template file at: ../data/templates/Markdown.md. .PARAMETER path - Specifies the path and new filename + Specifies the path and new filename (README.md by default) .EXAMPLE - PS> ./new-markdown-file.ps1 letter.md - ✅ New Markdown file 'letter.md' created from template 'Markdown.md'. + PS> ./new-markdown-file.ps1 + ✅ New file 'README.md' created from template 'Markdown.md'. .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> -param([string]$path = "") +param([string]$path = "README.md") try { - if ($path -eq "" ) { $path = Read-Host "Enter the new filename" } - $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/Markdown.md" Copy-Item $pathToTemplate "$path" if ($lastExitCode -ne 0) { throw "Can't copy template to: $path" } - "✅ New Markdown file '$path' created from template 'Markdown.md'." + "✅ New file '$path' created from template 'Markdown.md'." exit 0 # success } catch { "⚠️ Error: $($Error[0])" diff --git a/scripts/new-text-file.ps1 b/scripts/new-text-file.ps1 index 2a3e965e..727f8cc7 100755 --- a/scripts/new-text-file.ps1 +++ b/scripts/new-text-file.ps1 @@ -4,26 +4,24 @@ .DESCRIPTION This PowerShell script creates a new .txt file from template file at: ../data/templates/Text.txt. .PARAMETER path - Specifies the path and new filename + Specifies the path and new filename (README.txt by default) .EXAMPLE - PS> ./new-text-file.ps1 README.txt - ✅ New text file 'README.txt' created from template 'Text.txt'. + PS> ./new-text-file.ps1 + ✅ New file 'README.txt' created from template 'Text.txt'. .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> -param([string]$path = "") +param([string]$path = "README.txt") try { - if ($path -eq "" ) { $path = Read-Host "Enter the new filename" } - $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/Text.txt" Copy-Item $pathToTemplate "$path" if ($lastExitCode -ne 0) { throw "Can't copy template to: $path" } - "✅ New text file '$path' created from template 'Text.txt'." + "✅ New file '$path' created from template 'Text.txt'." exit 0 # success } catch { "⚠️ Error: $($Error[0])"