Page 3 of 3

Re: Help with a script

Posted: 19 Feb 2021 11:51
by highend
Because the item to display needs focus, not a selection state.

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") {
        // Set focus to make it available in the preview pane...
        $jpgPaneContent = listfolder($dstFolder);
        sel gettokenindex($jpgFile, $jpgPaneContent);
        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";
My last contribution to this^^

Help with a script

Posted: 20 Feb 2021 04:29
by Memyself
Thank you for the amended script. However, now there is a mismatch between the selected jpg and the jpg on the preview pane during the script execution as shown in the attached picture.

Help with a script

Posted: 21 Feb 2021 05:14
by Memyself
Furthermore, I noticed this error only happens when there are files either other than jpg files or other folders inside the prefix folder.

However, when I tried to apply the script to a folder containing only pdf files, I got an error message. Both are attached herewith:
// Position of the XYplorer inputselect() window
$xPos = 200;
$yPos = 150;
$rememberPositionExe = "C:\Users\Test\AppData\Roaming\XYplorer\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 .pdf(s) reside");

$prefix = gettoken($dstFolder, -1, "\");
$pdfFiles = listfolder($dstFolder, "*.pdf", 1+4, <crlf>);
end (!$pdfFiles), "No .pdf 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($pdfFile, $pdfFiles, <crlf>, "e") {
// Set focus to make it available in the preview pane...
$pdfPaneContent = listfolder($dstFolder);
sel gettokenindex($pdfFile, $pdfPaneContent);
colorfilter($pdfFile . ">FFFFFF,00FF00");
#1012; // Move focused item into view

$suffix = inputselect("Suffix for $pdfFile", $menu, <crlf>, 4+32+4096+8192+16384, "not_named", 400, 600, $winTitle);
if ($suffix LikeI "not_named") { continue; }
renameitem("$prefix $suffix", $dstFolder . "\" . $pdfFile, 1, "-01");
}
copytext "QUIT";

Re: Help with a script

Posted: 24 Feb 2021 21:52
by highend
I don't have mismatches here, when executing the latest script...
The correct jpg file is selected, focused and displayed in the preview pane

Regarding .pdfs, which preview handler for them is used?

Help with a script

Posted: 24 Feb 2021 23:56
by Memyself
I used $pdfPaneContent = listfolder($dstFolder); as pdf preview handler.

I am getting issues with jpg files when there non-jpg files in the same prefix folder. If non-jpgs files are not present, the script works fine.