File tree 3 files changed +41
-3
lines changed 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 1
1
Your Headline
2
- ============
2
+ =============
3
3
4
4
Some introductory words...
5
5
6
- - Point 1
7
- - Point 2
6
+ 1 . Do this...
7
+ 2 . Do that...
Original file line number Diff line number Diff line change
1
+ Your Headline
2
+ =============
3
+
4
+ Some introductory words...
5
+
6
+ 1. Do this...
7
+ 2. Do that...
Original file line number Diff line number Diff line change
1
+ <#
2
+ . SYNOPSIS
3
+ Creates a new text file
4
+ . DESCRIPTION
5
+ This PowerShell script creates a new .txt file from template file at: ../data/templates/Text.txt.
6
+ . PARAMETER path
7
+ Specifies the path and new filename
8
+ . EXAMPLE
9
+ PS> ./new-text-file.ps1 README.txt
10
+ ✅ New text file 'README.txt' created from template 'Text.txt'.
11
+ . LINK
12
+ https://github.com/fleschutz/PowerShell
13
+ . NOTES
14
+ Author: Markus Fleschutz | License: CC0
15
+ #>
16
+
17
+ param ([string ]$path = " " )
18
+
19
+ try {
20
+ if ($path -eq " " ) { $path = Read-Host " Enter the new filename" }
21
+
22
+ $pathToTemplate = Resolve-Path " $PSScriptRoot /../data/templates/Text.txt"
23
+ Copy-Item $pathToTemplate " $path "
24
+ if ($lastExitCode -ne 0 ) { throw " Can't copy template to: $path " }
25
+
26
+ " ✅ New text file '$path ' created from template 'Text.txt'."
27
+ exit 0 # success
28
+ } catch {
29
+ " ⚠️ Error: $ ( $Error [0 ]) "
30
+ exit 1
31
+ }
You can’t perform that action at this time.
0 commit comments