Wednesday, June 19, 2019

Take Note (daily)!

Created this simple PowerShell script this afternoon to create a txt file, and append the date and time, in order to make tracking my time easier.

A couple of notes:
- Script will auto-detect environment variable for default "ProgramFiles" location. However, it has no error handling if you are running x64-bit Windows, but an x86-bit Application.
- I am using an auto save plugin for Notepad++, so no data is lost when I run this multiple times per day to input the most recent timestamp.
- You must either create a \notes\daily directory in your Documents folder, or change that variable to reflect your desired location.

- This is v1, so be ruthless with your testing and please let me know of issues.

<#
####################
Author: Sam Dye
Date: 2019-06-19
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: "dnote.ps1"

#>

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

Add-Content -Path ($DailyNotesDir + $Date + ".txt") `
"
#=====================#
$($DateTime)
#=====================#"

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

No comments:

Post a Comment