Page 1 of 1

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

Posted: 15 Jan 2022 17:18
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"; }

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

Posted: 15 Jan 2022 17:58
by highend
?

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

Posted: 15 Jan 2022 18:06
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?

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

Posted: 15 Jan 2022 18:18
by highend
That looks like two different tab paths...

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

Posted: 15 Jan 2022 18:42
by Norn
Edit...

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

Posted: 15 Jan 2022 19:00
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 ^^

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

Posted: 15 Jan 2022 19:27
by Norn
Thanks for the tip.

Code: Select all

    $path = replace($path,:,);

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

Posted: 15 Jan 2022 19:28
by highend
Args... Tick Menu - Scripting - [x] Syntax Checking