Hi highend, your script gave me an idea of how I could do something similar but to geared to suite my needs. Maybe some others would find value in it. Instead of closing all tabs to the right of the current tab, this modification will close all tabs to the right of your normal setup's right most tab regardless of what tab is currently selected.
In my particular case my normal rightmost tab is my "default" tab which I name Roaming with the drive after it (e.g., Roaming <drive>:\<folder>|:browsenetwork). Obviously that name could be changed to suit whatever the user normally has. I know I could have used an index number or ID, but I wanted to be able to use the the same script on 3 different computers which have different rightmost tab IDs and indexes. The one thing is common however is the fact that they all have the right most tab set as the default and it's caption is Roaming folowed by the drive letter. I'll start using this bit of code in my script that works hand-in-hand with my USBDLM script - a script which recognizes external drive attachment/removal and opens and closes tabs associated with the drives.
Code: Select all
$i = tab("get", "count")+1; //add "1" since the first decrement in the while loop will subtract 1 from the total
while ($i-- > 0) { //worked backwards from the higher index tabs to reduce the reguired loops for this situation
$tabCaption = tab("get", "caption", $i);
if ($tabCaption LikeI "Roaming*") {end 1;} //change "Roaming*" to suit
else {tab("close", 0, $i); } //close tabs whether locked or not
}