Help with a script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

Just one more point: is it possible to highlight each jpg when the loop is executed?

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script

Post by highend »

Does that mean that you have the folder in which the .jpg files reside opened in dual pane mode in the other pane?

If that's the case, show a screenshot...
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

The jpg and the "renames" are in the same folder in a single pane.

As you can see from the attached printscreen, when a jpg is selected for renaming, the jpg itself is not highlighted. This makes it to difficult to locate the relevant jpg before accepting to rename or skip it, as the menu itself keeps jumping on the screen from one selection to the next.
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script

Post by highend »

Code: Select all

    end (<get countselected> == 0), "No item(s) selected, aborted!";

    $dstFolder = inputfolder(, "Choose folder where the .jpg(s) reside");
    $prefix    = gettoken($dstFolder, -1, "\");
    $jpgFiles  = listfolder($dstFolder, "*.jpg", 1+4, <crlf>);
    end (!$jpgFiles), "No .jpg file(s) found in destination folder, aborted!";

    $menu = regexreplace(<get SelectedItemsNames <crlf>>, "^(.+?)(\.[^.]+?)(?=\r?\n|$)", "$1");

    foreach($jpgFile, $jpgFiles, <crlf>, "e") {
        selectitems $jpgFile, , 1;
        colorfilter($jpgFile . ">FFFFFF,00FF00");
        #1012; // Move focused item into view

        $suffix = inputselect("Suffix for $jpgFile", $menu, <crlf>, 4+32+4096+8192+16384, "not_named", 400, 600);
        if ($suffix LikeI "not_named") { continue; }
        renameitem("$prefix $suffix", $dstFolder . "\" . $jpgFile, 1, "-01");
    }
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

It works. Thank you very much.

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

One last thing: how do you stop the menu from jumping across the screen when it goes through the loop?
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script

Post by highend »

That dialog window should be centered on the screen each time it appears and not wander around...
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

How shall the script be modified to stop the menu from wandering around??

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script

Post by highend »

The script is not responsible for the dialog to appear in a different position and it can't fix it.

Don't know what's causing this on your system...
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

You are right. The dialog appears always in the center of the screen. I am wondering whether it is possible to freeze the dialog in a fixed position throughout the execution of the script.

Another point that I noticed is that the highlighted jpg does not appear in the preview pane during the script execution. Is this a limitation of the application or can it be sorted out? This could be another way of overcoming the fact that during the execution of the script the dialog hides the highlighted jpg.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script

Post by highend »

Adapt the path to the .exe in the script and the position variables as well!

Code: Select all

    // Position of the XYplorer inputselect() window
    $xPos = 200;
    $yPos = 150;
    $rememberPositionExe = "D:\Tools\Remember XYplorer inputselect window.exe";

    // ========================================================================
    // == DO NOT CHANGE ANYTHING BELOW IF YOU DO NOT KNOW WHAT YOU ARE DOING ==
    // ========================================================================

    $winTitle = "XYplorer inputselect";
    end (<get countselected> == 0), "No item(s) selected, aborted!";

    $dstFolder = inputfolder(, "Choose folder where the .jpg(s) reside");
    $prefix    = gettoken($dstFolder, -1, "\");
    $jpgFiles  = listfolder($dstFolder, "*.jpg", 1+4, <crlf>);
    end (!$jpgFiles), "No .jpg file(s) found in destination folder, aborted!";

    if (exists($rememberPositionExe) == 1) {
        run """$rememberPositionExe"" $xPos $yPos ""$winTitle""";
    }
    $menu = regexreplace(<get SelectedItemsNames <crlf>>, "^(.+?)(\.[^.]+?)(?=\r?\n|$)", "$1");

    foreach($jpgFile, $jpgFiles, <crlf>, "e") {
        selectitems $jpgFile, , 1;
        colorfilter($jpgFile . ">FFFFFF,00FF00");
        #1012; // Move focused item into view

        $suffix = inputselect("Suffix for $jpgFile", $menu, <crlf>, 4+32+4096+8192+16384, "not_named", 400, 600, $winTitle);
        if ($suffix LikeI "not_named") { continue; }
        renameitem("$prefix $suffix", $dstFolder . "\" . $jpgFile, 1, "-01");
    }
    copytext "QUIT";
Remember XYplorer inputselect window_v0.1.zip
To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Help with a script

Post by klownboy »

Curious though as to why the inputselect box was moving around for Memyself I tried the script in a number of views including tiles and thumbnail views and got no movement. At first I thought it might be the setting PopupMenusAtSelection=0 | 1, but it had no affect for SC inputselect. Though maybe it's another setting is affecting it.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script

Post by highend »

He moved it himself...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Help with a script

Post by klownboy »

Ha Ha! Maybe it was me, myself or I. :)

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

Thank you very much, it now works as intended.

Could you please clarify why the highlighted jpg does not appear in the preview pane during the script execution?

Thank you.

Post Reply