[solved] script that does not work anymore

Discuss and share scripts and script files...
Post Reply
lian00
Posts: 365
Joined: 09 Jul 2014 17:12

[solved] script that does not work anymore

Post by lian00 »

Hello, for some reason this code does not work as intended. It’s supposed to resize images with XnViewMP. it works with one image but not if I select multiple images (the first image will be resized again and again). If I fix the size, it seems to work correctly. The script worked some monthes ago.

Code: Select all

"Redim au choix"
	foreach($file, "<get SelectedItemsPathNames |>") {
        $ext     = gpc($file, "ext");
        $oldName = gpc($file, "base");
        $newName = replace(recase($oldName, "lower"), " ", "-");
        rename "s", "$oldName/$newName";
    }
     $largeur = input("La plus grande taille max", "Entrer valeur");
    wait 300;
    foreach($file, "<get SelectedItemsPathNames |>") {
        runret("""C:\Program Files\nconvert\nconvert.exe"" -ratio -rtype lanczos -rflag orient -quiet -resize longest"." $largeur"." -out jpeg -o ""E:\images\Output\%.jpg"" ""<curpath>\$newName.$ext""");
        }
        end confirm ("Allez à Output ?") == 0;
          goto "E:\images\Output";
Thanks for any help.
Last edited by lian00 on 22 Mar 2020 11:36, edited 1 time in total.
Windows 10 64 bits

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

Re: script that do not work anymore

Post by highend »

The script worked some monthes ago
Probably not.

Your second foreach loop always processes the last created $newName from the first foreach loop.

E.g. 3 selected files:

Code: Select all

001 Picture.jpg
002 Picture.jpg
003 Picture.jpg
The first foreach loop leaves "003-picture.jpg" as $newName (+ $ext) after it's finished, so your second loop will only process that specific file...
One of my scripts helped you out? Please donate via Paypal

lian00
Posts: 365
Joined: 09 Jul 2014 17:12

Re: script that do not work anymore

Post by lian00 »

Thanks for pointing the problem. I must have paste and copy some more codes when I met problem some times ago and did not noticed the double loop – as I’m a very noob in code. :tup:
Windows 10 64 bits

Post Reply