Open Selected Items in New Background Tabs

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
amirvf
Posts: 133
Joined: 18 Oct 2020 00:46

Open Selected Items in New Background Tabs

Post by amirvf »

I want to write a script to open the selected items in new background tabs. I want to use this script in custom event actions.

Here is my goal:
Several items are selected. Selected items could be files or folders.
The script should check all selected items and do the following job:
- If the selected item is a "File" → The folder containing the selected file should open in a new background tab.
- If the selected item is a "Folder" → The selected folder should open in a new background tab.

My attempt failed at the very beginning step. I have selected 5 folders and I use the "tab" command as follows:

Code: Select all

 $ItemsAddress = get("SelectedItemsPathNames");
 tab("newb", "$ItemsAddress");
It only opens the first selected folder in the background and other items are ignored. Even the first opened background tab does not work correctly and shows the content correctly after a refresh.

Adding separators does not resolve the issue.

Code: Select all

tab("newb", "$ItemsAddress","Separator= <crlf>");
Any comments of how to solve the problem?

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

Re: Open Selected Items in New Background Tabs

Post by highend »

Code: Select all

    $ItemsAddress = get("SelectedItemsPathNames");
    foreach($entry, $ItemsAddress, <crlf>, "e") {
        if (exists($entry) == 2) { tab("newb", $entry); }
        else { tab("newb", getpathcomponent($entry, "path"); }
    }
?
One of my scripts helped you out? Please donate via Paypal

amirvf
Posts: 133
Joined: 18 Oct 2020 00:46

Re: Open Selected Items in New Background Tabs

Post by amirvf »

highend wrote: 12 Jun 2021 00:04

Code: Select all

    $ItemsAddress = get("SelectedItemsPathNames");
    foreach($entry, $ItemsAddress, <crlf>, "e") {
        if (exists($entry) == 2) { tab("newb", $entry); }
        else { tab("newb", getpathcomponent($entry), "path"); }
    }
?
Excellent. Both jobs are done in a simpler way!

amirvf
Posts: 133
Joined: 18 Oct 2020 00:46

Re: Open Selected Items in New Background Tabs

Post by amirvf »

highend wrote: 12 Jun 2021 00:04

Code: Select all

    $ItemsAddress = get("SelectedItemsPathNames");
    foreach($entry, $ItemsAddress, <crlf>, "e") {
        if (exists($entry) == 2) { tab("newb", $entry); }
        else { tab("newb", getpathcomponent($entry), "path"); }
    }
?
Hi,
This script was working quite fine so far.
Recently I noticed an error message pops up indicating Tab name not found for the following line:
tab("newb", getpathcomponent($entry), "path");

I am running XYplorer: 25.50.0000.

Any ideas?
Background Tab.jpg
Background Tab.jpg (127.29 KiB) Viewed 149 times

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Open Selected Items in New Background Tabs

Post by jupe »

tab("newb", getpathcomponent($entry, "path"));

amirvf
Posts: 133
Joined: 18 Oct 2020 00:46

Re: Open Selected Items in New Background Tabs

Post by amirvf »

Thanks. It works again!

Post Reply