Help with a script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script

Post 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^^
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 »

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.
To see the attached files, you need to log into the forum.

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

Help with a script

Post 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";
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 »

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?
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 »

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.

Post Reply