Improved list-memos.ps1 and remember.ps1

This commit is contained in:
Markus Fleschutz
2024-05-29 20:31:08 +02:00
parent e52a77bba2
commit 5dd0c7ce9f
2 changed files with 26 additions and 25 deletions

View File

@@ -1,8 +1,8 @@
<#
.SYNOPSIS
Lists your memo entries
Lists your remembered entries
.DESCRIPTION
This PowerShell script lists all memo entries in Memos.csv in your home folder.
This PowerShell script lists all entries in 'Remember.csv' in your home folder.
.EXAMPLE
PS> ./list-memos.ps1
.LINK
@@ -11,26 +11,23 @@
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = "~/Memos.csv"
if (Test-Path "$Path" -pathType leaf) {
write-progress "Reading $Path ..."
$Table = Import-CSV "$Path"
write-progress -completed "Reading $Path"
""
"Time Text"
"---- ----"
foreach($Row in $Table) {
$Time = $Row.Time
$Text = $Row.Text
"$Time $Text"
}
} else {
"Sorry, no memos saved yet"
$path = "~/Remember.csv"
if (-not(Test-Path "$path" -pathType leaf)) {
"Nothing to remember."
exit 1
}
Write-Progress "Reading $path ..."
$table = Import-CSV "$path"
Write-Progress -completed "Done."
foreach($row in $table) {
$unixTimestamp = [int64]$row.TIMESTAMP
$time = (Get-Date -day 1 -month 1 -year 1970 -hour 0 -minute 0 -second 0).AddSeconds($unixTimestamp)
$text = $row.TEXT.trim()
"⚠️ NOTE: $text (remembered $time)"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"