diff --git a/public/getNotes.ps1 b/public/getNotes.ps1 index 60bf492..1d7fba1 100644 --- a/public/getNotes.ps1 +++ b/public/getNotes.ps1 @@ -21,14 +21,17 @@ function Get-Notes () { [Alias("notes")] param( [Parameter()][string] $Filter, + [Parameter()][int32] $DaysAgo, #all [Parameter()][switch] $All ) + $DaysAgo = $DaysAgo -eq 0 ? 15 : $DaysAgo + $notes = GetNotes -Filter $filter # Filter out files that are older than 30 days - $ret = $All ? $notes : ($notes | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-30) }) + $ret = $All ? $notes : ($notes | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-$DaysAgo) }) # Create a custom object with required properties $ret = $ret | ForEach-Object { @@ -74,7 +77,8 @@ function GetNotesCategory { ) process{ - (($Path | Split-Path -Leaf) -split '-|\.')[1] + $ret = (($Path | Split-Path -Leaf) -split '-|\.')[1] + return $ret } diff --git a/public/newNotes.ps1 b/public/newNotes.ps1 index 09a7b16..10ad17d 100644 --- a/public/newNotes.ps1 +++ b/public/newNotes.ps1 @@ -38,6 +38,11 @@ function New-Note{ $Date = Get-Date -Format "yyMMdd" } + if([string]::IsNullOrWhiteSpace($Date)) { + Write-Error "Date is empty. Consider using -DateToday or -Date to specify a date for the note." + return + } + $fileName = getFileName -Category $Category -Section $Section -Title $Title -Date $Date # Create the note base folder