Change Default Collection Path

I have a button that displays the path name of the given tab.

@label:="   " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source)

When running a search, the collection path created is a string like below

How might one change this to another name so that when a search is run, the resulting path name (alias maybe?) is something more useful like YYYY-MM-DD-HH-MM-SS_SearchCriteria

For example: 2025-12-07-08-30-21_Automobile

Try using the DisplayName() function, it should return a nicer string than the underlying path.

The difficulty for me is maintaining my chosen format if it's NOT a search result (i.e., "C:\...\Documents"

I've tried several combinations with no success. Here's an example:

@ifpath:InStr(sourcepath, "coll",0)
@label:=DisplayName(source,"r")
@ifpath:else
@label:="   " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source)

What am I missing?

You need to put the logic in the @label line, @ifpath won't work for that.
Something like:

@label:=InStr(sourcepath,"coll",0)?DisplayName(source,"r"):("   " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source))

The button label no longer changes based on the path, it simply states "Path", the default label.

I have simplified this as much as possible to just test if it detects "coll" in the sourcepath:

@label:=InStr(sourcepath, "coll",0) ? DisplayName(source,"r")

Script log:

Error at line 1, position 7 [Button:Path - @label] 
Unknown value (6): sourcepath

It should be source not sourcepath I think.

@label:=InStr(source, "coll",0) ? DisplayName(source,"r")

Name for search does NOT change; keeps prior path name.

Script log:

Error at line 1, position 49 [Button: Path - @label]
Syntax error (5): )
InStr(source, "coll",0) ? DisplayName(source,"r")

You've simplified it to the point of error. The syntax must be a ? b : c, a ? b is wrong.

It might also be better to use PathType() instead of InStr() to detect a collection.

Try something like:

PathType(source) == "coll" ? DisplayName(source, "r") : ("   " + (Count(source)>2 ? Root(source) + "\..\" + FilePart(source) : source))
1 Like

That's it. Thanks Jon!