Page 1 of 1

Open Selected Items in New Background Tabs

Posted: 11 Jun 2021 23:40
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?

Re: Open Selected Items in New Background Tabs

Posted: 12 Jun 2021 00:04
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"); }
    }
?

Re: Open Selected Items in New Background Tabs

Posted: 12 Jun 2021 01:34
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!

Re: Open Selected Items in New Background Tabs

Posted: 05 Feb 2024 23:03
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 784 times

Re: Open Selected Items in New Background Tabs

Posted: 05 Feb 2024 23:11
by jupe
tab("newb", getpathcomponent($entry, "path"));

Re: Open Selected Items in New Background Tabs

Posted: 05 Feb 2024 23:25
by amirvf
Thanks. It works again!