[Feat Request]: Add COALESCE & WHERE

Discussion related to "Everything" 1.5.
Post Reply
DerekZiemba
Posts: 54
Joined: Thu Sep 27, 2018 4:46 pm

[Feat Request]: Add COALESCE & WHERE

Post by DerekZiemba »

COALESCE:
To turn this monstrosity
col2:=IFS(!IS_BLANK($DateReleased:),$DateReleased:,!IS_BLANK($DateEncoded:),FORMAT_DATETIME($DateEncoded:),!IS_BLANK($DateTaken:),FORMAT_DATETIME($DateTaken:),!IS_BLANK(GETPROPERTY($FullPath:,"Recorded date")),GET_PROPERTY($FullPath:,"Recorded date"),!IS_BLANK($Date:),FORMAT_DATETIME($Date:),1,$DateModified:)
Into:
col2:=COALESCE($DateReleased:,FORMAT_DATETIME($DateEncoded:),FORMAT_DATETIME($DateTaken:),GET_PROPERTY($FullPath:,"RecordedDate"),FORMAT_DATETIME($Date:),1,FORMAT_DATETIME($DateModified:))
Or:
col2:=COALESCE($DateReleased:,GET_PROPERTY($FullPath:,"Recorded date"),FORMAT_DATETIME(COALESCE($DateEncoded:,$DateTaken:,$Date:,$DateModified:)))
  • By GET_PROPERTY($FullPath:,"Recorded date") I was trying to get at a non-canonical property that shows up in MediaInfo that I later found to be in QuickTime Metadata. Then noticed that appears to be where $DateReleased: is actually already sourcing the value from.
  • $DateReleased: is a string value that sometimes is just the Year or some other oddly formatted date string Everything can't parse and format. In that case, I just want the raw string.
  • All other values appear to be numbers. COALESCE() should omit null-ish [sup]or should I say, void-ish[/sup] & invalid values.
WHERE:
Essentially want to do something like the following (powershell syntax):

Code: Select all

$col2 = @($DateReleased, $DateEncoded, $DateTaken, $Date, $DateModified) `
        | where { ($_ -is [number]) { $_ -gt 0 } else { -not [string]::IsNullOrWhiteSpace($_) } } `
        | select -First 1 { if ($_ -is [number]) { $_ -as [datetime] } else { $_ } };
Would need a way to refer to this . Following PowerShell's lead with $_ seems viable after Everything-ifying it by tacking on :
$_:
. I actually find myself wishing for something like this VERY often, is there already a way to refer to the current row/file I don't know about?

In Everything Syntax, I think it'd look something like:
FORMAT_DATETIME(WHERE(GREATER(TIMEVALUE($_:),0),$DateReleased:,$DateEncoded:,$DateTaken:,$Date:,$DateModified:))

* WHERE(condition,value1,value2,...)

Essentially COALESCE, but you can specify the condition.
void
Developer
Posts: 19870
Joined: Fri Oct 16, 2009 11:31 pm

Re: [Feat Request]: Add COALESCE & WHERE

Post by void »

I have put COALESCE and WHERE on my TODO list.
Thank you for the suggestion.
Post Reply