Rename tabs to first 9 characters

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
dogeatdog
Posts: 42
Joined: 29 Sep 2019 04:04

Rename tabs to first 9 characters

Post by dogeatdog »

is it possible to rename tabs to a variable like the first 9 characters of a folder?

Norn
Posts: 416
Joined: 24 Oct 2021 16:10

Re: Rename tabs to first 9 characters

Post by Norn »

Code: Select all

//Rename tabs to first 9 characters of folder
 $tabs = get("tabs", "|");
 foreach($tab, $tabs, "|") {
	$count++;
	$path = tab("get", "path", $count);
	$base = gpc($path, "base");
	$newCapation = substr($base, 0, 9);
	tab("rename", $newCapation, $count);
	}
Win10, Win11 @100% 2560x1440 22H2

dogeatdog
Posts: 42
Joined: 29 Sep 2019 04:04

Re: Rename tabs to first 9 characters

Post by dogeatdog »

Norn that's incredible thank you very much.

One annoying request is can the tab somehow update automatically when changing directory? I notice the tab just has a text field, I tried to have it load a script but I couldn't get it to work.

I would be so grateful to get this working.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Rename tabs to first 9 characters

Post by highend »

tab("rename", substr(gpc(tab("get", "path"), "base"), 0, 9));

and use it as a script for: configuration - custom event actions => after painting the file list?
One of my scripts helped you out? Please donate via Paypal

dogeatdog
Posts: 42
Joined: 29 Sep 2019 04:04

Re: Rename tabs to first 9 characters

Post by dogeatdog »

Thank you highend I love this community so much.

Is it possible to exclude some tabs somehow or only apply the script to the first two tabs on a given pane? It's always the same tabs they are locked and don't move only on the first pane.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Rename tabs to first 9 characters

Post by highend »

Code: Select all

    if (regexmatches(tab("get", "id"), "^(1|2)$")) {
        tab("rename", substr(gpc(tab("get", "path"), "base"), 0, 9));
    }
?
One of my scripts helped you out? Please donate via Paypal

dogeatdog
Posts: 42
Joined: 29 Sep 2019 04:04

Re: Rename tabs to first 9 characters

Post by dogeatdog »

Highend, you are impressive.

Thank you very much, works perfectly :appl: :tup:

Garonne
Posts: 116
Joined: 21 Apr 2015 19:10
Location: Germany
Contact:

Re: Rename tabs to first 9 characters

Post by Garonne »

highend wrote: 12 Aug 2022 07:45

Code: Select all

    if (regexmatches(tab("get", "id"), "^(1|2)$")) {
        tab("rename", substr(gpc(tab("get", "path"), "base"), 0, 9));
    }
?
That should be extendable with "special" handling for tabs you might want to name individually, right?
That's not a request for another update of your code, though... If I need another if...then...else I'm sure, that's done easily enough if I take the time to dive into the scripting guide...

Post Reply