Set ListerTitle Question

I use a script to customize the lister title. Due to potentially long directory names, I have the title display as the following:

%R\\...\\%N

For example, the documents directory will display as

C:\...\Documents

Rather than

C:\Users\Username\Documents

However, when I go to the root drive, the title will display

C:\...C:\

How can I make it simply display C:\

Appreciate any help!

If a script is changing the title, it could check the path and use a different title when in the root of a drive.

@Leo, I suspected as much; figured it out:

if (tab.path.root == false)
{
     title = "%R\\"
} else
{
     title = "%R\\...\\%N"
}
1 Like

@Leo, @Jon and all the smart DOpus users:

Appreciate any assistance!

Not sure if I'm understanding correctly.

You're setting the title to %R\ ("%R\\" in jscript) and wondering why there is a \ on the end? It's on the end because you put it there. :slight_smile:

@Leo,

I'm using jscript. I corrected the first issue (ie Desktop), but now the root drive displays as "C:" without the slash. I prefer the slash, which is why I set it up as "%R\" in the first place. I'm stuck, unless you have a suggestion for this.

I also still have an issue with "My PC"

It displays as "My PC\...\My PC"

Again, appreciate any help!

Maybe try the Path.components property; more than 1 component, do the .. thing, only 1 component just show the path as is?

@Jon, that provides the same result as using tab.path.root

Maybe something with Alias or Aliases?

Actually components returns 0 for This PC. I'm not sure why you can't make that work. Fundamentally it's you who's adding the backslash, all you need to do is work out when not to add it and not add it.

image

Path.components seems to return 2 for This PC (/mycomputer) when run against a lister, I think due to it having to ':' in the special kind of path that designates that kind of folder.

But Path.root seems to work fine to me:

@Leo & @Jon,

Thank you both for the input. It appears DOpus sees both C: and My PC as root drives, and I only want the slash after C:, not after My PC or any other system/DOpus alias. While I'm sure there's a way to differentiate between the two, I don't know it.

If you only want a \ after paths ending in :, then check the last letter of the path to see if it's a :.

I tried this:

var id = tab.path;
	if (tab.path.root == false) //Check if at root drive  
	{
		if (id.substr(id.length - 1) == ":")
		{
			title = title + "   |   FOLDER:  %R"; 
		} else
		{
			title = title + "   |   FOLDER:  %R\\";
		}
	} else
	{
		title = title + "   |   FOLDER:  %R\\...\\%N";
	}

Output defaults to last else statement ("%R\...%N") in every case.

Any idea what I am missing?

You should use: if (tab.path.root) or if (!tab.path.root) rather than test against true or false.

tab.path is an object. Its length will be undefined. If you want to access as a string you can use tab.path.def_value.

Looking again, you also want to use path.test_root instead of path.root.

One tells you if the path is the root. The other modifies the path so it is the root of whatever it was previously.

@Leo and @aussieboykie Thank you both for clarifying, and thanks @Leo for your patience.

It now works!

1 Like