Copy Handler Issue / Hotkey for SendTo

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Kryzalin
Posts: 8
Joined: 24 Oct 2016 11:28

Copy Handler Issue / Hotkey for SendTo

Post by Kryzalin »

I have two questions involving two separate functions.

1.
I've recently started using the XY copy handler. I have the setting set to "Ask" on name collisions. Most of the time the option "Overwrite if newer" is the option I want, but on rare occasions one of the other options are used. I recently used the "Suffix increment to copy" and ever since every time I copy that is the selected choice. I now have to select "Overwrite if newer" manually every time I want to perform that option. I'm guessing because it defaulted to "Suffix increment to copy" it is meant to remember the last used option, but it doesn't seem to do this. I don't know if this is a bug or if I'm missing something. Anyone?

EDIT (Video Link Added):
Video (OneDrive) [00:00:34 - 1.02 MB]
https://1drv.ms/v/s!AuWTOtVLDJGXi0F0Z88 ... K?e=yTcZrI

2.
I set a custom hotkey to take selected files/folders and copy them to a windows SendTo shortcut. At it's core it works perfectly, but there are a couple minor issues. I just found a random script someone else requested on here and altered it to point to my .lnk file so I have no idea what the "s" means or what the | in the selitems part means. :)

Issue 1: I can only select a total of 46 files/folders for this operation. Is it possible to increase this limit?
Issue 2: The hotkey will not function on folders in the tree listing. Is it possible to add this functionality?

Script for the Hotkey:
openwith "%APPDATA%\Microsoft\Windows\SendTo\Notepad++.lnk", "s", <selitems |>;

I appreciate anyone who takes the time to help me out, thanks.
Last edited by Kryzalin on 19 Nov 2021 08:05, edited 1 time in total.

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

Re: Copy Handler Issue / Hotkey for SendTo

Post by highend »

1. No problem here with the new default action when I chose a different one

2. Just use the real N++ instead of the sendto shortcut?
Adapt the path!

Code: Select all

    $focus = get("FocusedControl");
    if     ($focus == "L") { $items = <selitems |>; }
    elseif ($focus == "T") { $items = <curpath>; }
    else   { msg "Neither tree nor list focused..."; end true; }
    end (!$items), "No item(s) to open...";
    openwith "D:\Tools\Notepad++_x64\notepad++.exe", "s", $items;
And you don't know what these options mean? Consult the help file...
One of my scripts helped you out? Please donate via Paypal

Kryzalin
Posts: 8
Joined: 24 Oct 2016 11:28

Re: Copy Handler Issue / Hotkey for SendTo

Post by Kryzalin »

I recorded a short 34 second video showing that the option to default back to "Overwrite if newer" seems to be broken. Also just to clarify, it won't default to anything other than "Suffix increment to copy".

Video (OneDrive) [00:00:34 - 1.02 MB]
https://1drv.ms/v/s!AuWTOtVLDJGXi0F0Z88 ... K?e=yTcZrI

That script looks like it'll add tree functionality for me, I'll get right on trying it, thank you. Also, I have no idea why I didn't just use the exe instead of lnk, makes a lot more sense though, definitely changing that, thanks again.
EDIT: This script is absolutely perfect, thank you very much.

As far as looking in the help file, I did I just couldn't figure out where to look. I looked in Scripting Commands and Variables with no luck and searching for "s" turned up nothing useful and searching just s wouldn't be useful either.

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

Re: Copy Handler Issue / Hotkey for SendTo

Post by highend »

I looked in Scripting Commands and Variables
Seriously?
openwith

Opens the currently selected (or list-defined) items with the specified application.

Syntax

openwith application, [mode (s|m)], [itemlist]

application [Required] Path to the application to open the selected items with.

mode Defines which mode to use when sending the parameters (item's names) to the application.

s: [Default] Single instance (pass all the items to the same instance of the application).

m: Multiple instance (pass each of the items to its own instance of the application).

itemlist CRLF- or |-separated list of items (full path) to open (overriding any List selections).
Variables <selitems ...> and <allitems ...>

The native variable <selitems...> returns the currently selected list items with full path. You can pass a separator (one or more characters; the space character is not possible here). If a separator is passed then the individual items are not quoted. Examples:

text "<selitems>"; //items are quoted, separated by space

text "<selitems ;>"; //items are separated by ;

text "<selitems |>"; //items are separated by |

text "<selitems //>"; //items are separated by //

text "<selitems <crlf>>"; //items are separated by CRLF

The native variable <allitems...> works exactly like <selitems>, but returns all list items, not only the selected ones.
One of my scripts helped you out? Please donate via Paypal

Kryzalin
Posts: 8
Joined: 24 Oct 2016 11:28

Re: Copy Handler Issue / Hotkey for SendTo

Post by Kryzalin »

Ahh I see it was in scripting commands. I was looking for just s in the list and didn't think to look in openwith. Sorry for the trouble, thank you for helping.

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

Re: Copy Handler Issue / Hotkey for SendTo

Post by highend »

Regarding 1st., select "Overwrite if newer" from the drop-down box and click on the OK button^^
One of my scripts helped you out? Please donate via Paypal

Kryzalin
Posts: 8
Joined: 24 Oct 2016 11:28

Re: Copy Handler Issue / Hotkey for SendTo

Post by Kryzalin »

F*** me I am a huge idiot, thank you again.

That script you wrote, it still seems to have some sort of file/folder amount limitation, but I can't make heads or tails of what it is. Using my old script I had a file/folder limitation of 46. It seems that I can't delete any amount of files if the total character count exceeds somewhere around 1115. For example I placed 187 txt files (001.txt-187.txt) on the root of my E drive, and it failed. I renamed 187.txt to 1 (no extension) and it worked. I then moved all the files into a subfolder named 1, attempted to delete and it failed, but performing the task on the single subfolder works. It seems to take a complete character count and fails when it exceeds that number. Is this something I can remedy or is it some kind of hardcoded limit?

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

Re: Copy Handler Issue / Hotkey for SendTo

Post by highend »

Delete? You were talking about opening (via N++)

Ofc you could rewrite the script to limit the number of files and send them as batches to N++ (e.g. 200 files selected, char size for all = ~ 10 kb and the script makes 10 batches out of them and send each one after another) because yes, there is a limit what applications accept via command line.
One of my scripts helped you out? Please donate via Paypal

Kryzalin
Posts: 8
Joined: 24 Oct 2016 11:28

Re: Copy Handler Issue / Hotkey for SendTo

Post by Kryzalin »

I think I need sleep because I have no idea why I wrote delete. Anyway thanks again for your help and tolerating me while mentally challenged.

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

Re: Copy Handler Issue / Hotkey for SendTo

Post by highend »

Set this tweak before you continue!
viewtopic.php?p=123479#p123479

https://www.xyplorer.com/faq-topic.php?id=tweak

Code: Select all

    $limit = 1000; // Max characters to send as full paths

    $editor = "D:\Tools\Notepad++_x64\notepad++.exe";
    end (exists($editor) != 1), quote($editor) . <crlf 2> . "does not exist, aborted!";

    $focus = get("FocusedControl");
    if     ($focus == "L") { $items = <selitems |>; }
    elseif ($focus == "T") { $items = <curpath>; }
    else   { msg "Neither tree nor list focused..."; end true; }
    end (!$items), "No item(s) to open...";

    // Send in batch(es)
    while (true) {
        $len = strlen($items);
        if (!$len) { break; }

        // Execute if remaining item(s) <= our limit
        if ($len <= $limit) {
            openwith """$editor""", "s", $items;
            break;

        // No...
        } else {
            // Check char at limit position
            $charAtPos = substr($items, $limit - 1, 1);

            // If it is a separator ("|"), split there
            if ($charAtPos == "|") {
                $newItems = substr($items, 0, $limit);
                openwith """$editor""", "s", $newItems;

                // Set remaining item list
                $items = substr($items, $limit);

            // We are behind our necessary split position
            } else {
                $newItems = substr($items, 0, $limit);
                $cnt      = gettoken($newItems, "count", "|") - 1;
                $newItems = gettoken($items, $cnt, "|", , 1);
                $items    = trim(replace($items, $newItems, , 1), "|", "L");

                openwith """$editor""", "s", $newItems;
            }
        }
    }
One of my scripts helped you out? Please donate via Paypal

Post Reply