[help] remove ending linebreaker of text

Discuss and share scripts and script files...
Post Reply
xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

[help] remove ending linebreaker of text

Post 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

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [help] remove ending linebreaker of text

Post 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");
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: [help] remove ending linebreaker of text

Post 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 :)

Post Reply