Page 1 of 1

[solved] script that does not work anymore

Posted: 22 Mar 2020 09:58
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.

Re: script that do not work anymore

Posted: 22 Mar 2020 11:27
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...

Re: script that do not work anymore

Posted: 22 Mar 2020 11:36
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: