diff --git a/data/templates/Markdown.md b/data/templates/Markdown.md index e3acd8a8..c0c9556e 100644 --- a/data/templates/Markdown.md +++ b/data/templates/Markdown.md @@ -1,7 +1,7 @@ Your Headline -============ +============= Some introductory words... -- Point 1 -- Point 2 +1. Do this... +2. Do that... diff --git a/data/templates/Text.txt b/data/templates/Text.txt new file mode 100644 index 00000000..c0c9556e --- /dev/null +++ b/data/templates/Text.txt @@ -0,0 +1,7 @@ +Your Headline +============= + +Some introductory words... + +1. Do this... +2. Do that... diff --git a/scripts/new-text-file.ps1 b/scripts/new-text-file.ps1 new file mode 100644 index 00000000..2a3e965e --- /dev/null +++ b/scripts/new-text-file.ps1 @@ -0,0 +1,31 @@ +<# +.SYNOPSIS + Creates a new text file +.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 +.EXAMPLE + PS> ./new-text-file.ps1 README.txt + ✅ New text file 'README.txt' created from template 'Text.txt'. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$path = "") + +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'." + exit 0 # success +} catch { + "⚠️ Error: $($Error[0])" + exit 1 +}