Page 1 of 1
Rename tabs to first 9 characters
Posted: 29 Jul 2022 13:01
by dogeatdog
is it possible to rename tabs to a variable like the first 9 characters of a folder?
Re: Rename tabs to first 9 characters
Posted: 03 Aug 2022 12:03
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);
}
Re: Rename tabs to first 9 characters
Posted: 11 Aug 2022 01:50
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.
Re: Rename tabs to first 9 characters
Posted: 11 Aug 2022 07:41
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?
Re: Rename tabs to first 9 characters
Posted: 12 Aug 2022 01:32
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.
Re: Rename tabs to first 9 characters
Posted: 12 Aug 2022 07:45
by highend
Code: Select all
if (regexmatches(tab("get", "id"), "^(1|2)$")) {
tab("rename", substr(gpc(tab("get", "path"), "base"), 0, 9));
}
?
Re: Rename tabs to first 9 characters
Posted: 12 Aug 2022 14:27
by dogeatdog
Highend, you are impressive.
Thank you very much, works perfectly

Re: Rename tabs to first 9 characters
Posted: 11 Nov 2022 17:10
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...