Page 1 of 1

[help] remove ending linebreaker of text

Posted: 16 Dec 2015 15:56
by xnmp
I 'm going to make extend "copy items path / name to clipboard" ,like this
1. like "ctrl + p" in xyplorer
2 . but it also support copy target path of shortcut file ".lnk" (also copy filepath of target file if selected files are window shortcut ".lnk" file) :
I found highend code and i edited it ,it works but the result has linebreaker at the end ,which i don't want:

Code: Select all

    $items = "";
    foreach($item, "<get SelectedItemsPathNames |>") {
        if (exists($item) != 1) { continue; }
        $shortcut = property("#ShortcutTarget", $item);
        if ($shortcut) { $item = $shortcut; }
        $items = $items . ($item) . "<br>";
    }
    trim("$items","<br>","R");
    copytext $items;
result :
e:/files/testfile1.doc
e:/files2/testfile2.doc
(this line has ending line breaker)
i want to remove/trim the ending linebreaker ,but this code does not work

Code: Select all

trim("$items","<br>","R");
Anybody please fix it for me ?
Thanks

Re: [help] remove ending linebreaker of text

Posted: 16 Dec 2015 16:46
by bdeshi
xnmp wrote: i want to remove/trim the ending linebreaker ,but this code does not work

Code: Select all

trim("$items","<br>","R");
it doesn't work because you aren't saving the result of the trim operation. So use this instead:

Code: Select all

$items = trim("$items","<br>","R");

Re: [help] remove ending linebreaker of text

Posted: 16 Dec 2015 17:11
by xnmp
SammaySarkar wrote:

Code: Select all

trim("$items","<br>","R");
it doesn't work because you aren't saving the result of the trim operation. So use this instead:

Code: Select all

$items = trim("$items","<br>","R");
Thank you very much ,it works like a charm :)