Tuesday, July 2, 2019

Take Note (named)!

In the last blog post, I published a short script to create / append the date/time to a simple text file. Which I use to keep track of tasks I've worked on throughout the day. However, what if I wanted to keep notes while training on a particular product, or keep notes on a client project. Digging through dozens of daily note files could become unwieldy. As they say on TV, "There's gotta be a better way!" And so there is, and here's my shot at it:

The same caveats from the last blog post apply here (won't detect x86-bit applications, if installed on a x64-bit OS; I'm using an auto-save plug-in for Notepad++, so no data is lost; and you must create a "notes\named" directory in your Documents folder, or change that variable to your desired path).

In the next iteration, I want to create a single application that detects whether or not you've supplied a name for the note, and if not create a daily note; and provide error handling for x86-bit applications on x64-bit OS's.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<#
####################
Author: Sam Dye
Date: 2019-07-02
Version: 1

####################
Pre-requisites:
1) Add script location to "Path" environment variable
2) Set PowerShell Execution Policy to RemoteSigned
3) Launch "Run.exe" and type: "nnote.ps1"
#>

param(
[Parameter(Mandatory=$true)]
[string]$NamedNote
)

$DateTime = Get-Date -UFormat %Y-%m-%d.%H:%M
$NamedNotesDir = ("C:\Users\" + ((Get-ChildItem Env:\USERNAME).Value) + "\Documents\notes\named\")

Add-Content -Path ($NamedNotesDir + $NamedNote + ".txt") `
"
#=====================#
$($DateTime)
#=====================#"

Start-Process -FilePath ((Get-ChildItem Env:\ProgramFiles).Value + '\Notepad++\notepad++.exe') -Argument ($NamedNotesDir + $NamedNote + ".txt")

No comments:

Post a Comment