Script question, how to get path but exclude certain characters?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Norn
Posts: 416
Joined: 24 Oct 2021 16:10

Script question, how to get path but exclude certain characters?

Post by Norn »

Such as ":".
Thanks.
Trying to edit the script. :whistle:

Code: Select all

/*
******************************************************************************
@Author  : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-01-14 20:09:47
@Function: Copyto, moveto, backupto to tab folders
@Tags    : <empty>
@Version : v0.1
******************************************************************************
*/

    $iconFolder  = ":showfolders";
    $iconCopy    = ":copyto";
    $iconMove    = ":moveto";
    $iconBackup  = ":backupto";

    $selectedItems = <get SelectedItemsPathNames |>;
    end (!$selectedItems), "No item(s) selected, aborted!";

    $folders = "";
    if (get("#800")) { $folders .= get("tabs", <crlf>, "i"); }
    $folders .= <crlf> . get("tabs", <crlf>);
    $folders  = formatlist($folders, "esdF", <crlf>, "!" . <curpath>);
    $path = input("Source path Edit: $selectedItems", ,<get path>,"w" , , 1000, 200);

    $menu   = "";
    $indent = <space 4>;
    $last   = "";

    while ($folders) {
        $folder  = gettoken($folders, 1, <crlf>);
        $folders = gettoken($folders, 2, <crlf>, , 2);

        if ($folder != $last) {
            $caption  = gpc($folder, "component", -1);
            $menu    .= <crlf> . $caption . "<:><:>" . $iconFolder;
        }

        $data  = ""copyto "$folder\$path","$selectedItems", , 2;
        $menu .= <crlf> . $indent . "Copy <selected items> here...<:>" . $data . "<:>" . $iconCopy;
        $data  = "moveto " . quote($folder) . ", " . quote($selectedItems) . ", , 2;";
        $menu .= <crlf> . $indent . "Move <selected items> here...<:>" . $data . "<:>" . $iconMove;
        $data  = "backupto " . quote($folder) . ", " . quote($selectedItems) . ", , 2;";
        $menu .= <crlf> . $indent . "Backup <selected items> here...<:>" . $data . "<:>" . $iconBackup;
        $last  = $folder;
    }
    $selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }
Last edited by Norn on 15 Jan 2022 18:12, edited 1 time in total.
Win10, Win11 @100% 2560x1440 22H2

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

Re: Script question, how to get path but exclude certain characters?

Post by highend »

?
One of my scripts helped you out? Please donate via Paypal

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

Re: Script question, how to get path but exclude certain characters?

Post by Norn »

G:\HG\D\E:\Cats\
to
G:\HG\D\E\Cats\
The folder name can't contain that ":", I've combined two paths,is there a way to exclude it?
Attachments
Couldn't create new path.png
Couldn't create new path.png (4.66 KiB) Viewed 670 times
Last edited by Norn on 15 Jan 2022 18:41, edited 5 times in total.
Win10, Win11 @100% 2560x1440 22H2

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

Re: Script question, how to get path but exclude certain characters?

Post by highend »

That looks like two different tab paths...
One of my scripts helped you out? Please donate via Paypal

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

Re: Script question, how to get path but exclude certain characters?

Post by Norn »

Edit...
Win10, Win11 @100% 2560x1440 22H2

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

Re: Script question, how to get path but exclude certain characters?

Post by highend »

Sorry, no clue what you really want but look at the replace() script command.

And you should definitely tick Menu - Scripting - [x] Syntax Checking ^^
One of my scripts helped you out? Please donate via Paypal

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

Re: Script question, how to get path but exclude certain characters?

Post by Norn »

Thanks for the tip.

Code: Select all

    $path = replace($path,:,);
Win10, Win11 @100% 2560x1440 22H2

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

Re: Script question, how to get path but exclude certain characters?

Post by highend »

Args... Tick Menu - Scripting - [x] Syntax Checking
One of my scripts helped you out? Please donate via Paypal

Post Reply