Script only executing one file then stopping

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

staylor43448
Posts: 4
Joined: Wed Aug 10, 2022 10:21 am

Script only executing one file then stopping

Post by staylor43448 »

Have a simple task of re-sizing multiple images, based on new canvas widths

I can knock up the commands using Excel, as I can put some maths into it to give me a list of canvas sizes etc

Each image will need a different canvas size

I'm testing what I've done with two images, but script only seems to working on first image, nothing happens after that

### -canvas 100 128 bottom-left
convert\2-FASCIA-ROOF-7-0-32-3-right.png
### -canvas 200 176 bottom-left
convert\2-FASCIA-ROOF-7-6-32-3-right.png

Do I need to add something after second line, to make it then continue on to next command?
cday
XnThusiast
Posts: 3484
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Only executing one file then stopping

Post by cday »

I am afraid that there is limited support for NConvert on the forum, and although I try to help when I can, with my limited knowledge I don't understand what you are trying to do! I assume that you are using Windows and the current NConvert version?

Are you somehow calling NConvert code from within Excel, if that is possible, or possibly trying to create a batch conversion loop that uses values exported from Excel?
staylor43448
Posts: 4
Joined: Wed Aug 10, 2022 10:21 am

Re: Only executing one file then stopping

Post by staylor43448 »

Thanks

Yes up to date Nconvert etc

Not using Excel as such, I'm going to use Excel to help me generate list of canvas sizes, then paste that into .txt file that Nconvert will run (there about 300 images, each of which need to be a slightly different canvas size)
cday
XnThusiast
Posts: 3484
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Only executing one file then stopping

Post by cday »

Useful clarification, as I say I can't follow your posted code, but there are ways of using NConvert with which I have no experience.

I would expect you to create a batch file .bat and use a loop, probably one of the For loop forms, to run NConvert code that calls variables containing the parameters that you are exporting from Excel. Does that make sense to you?
staylor43448
Posts: 4
Joined: Wed Aug 10, 2022 10:21 am

Re: Only executing one file then stopping

Post by staylor43448 »

I've based it on examples from the readme files that came with Nconvert

Screenshot attached

I've used it to perform tasks on multiple files before now, but one command covering all the files (i.e. simply list all the files first, then the command) - works a treat
You do not have the required permissions to view the files attached to this post.
cday
XnThusiast
Posts: 3484
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Only executing one file then stopping

Post by cday »

staylor43448 wrote: Wed Aug 10, 2022 11:48 am I've based it on examples from the readme files that came with Nconvert

I've used it to perform tasks on multiple files before now, but one command covering all the files (i.e. simply list all the files first, then the command) - works a treat
The file you are referring to is from the wiki and I have seen it before, but didn't understand the ### notation then and haven't seen it defined since.

My feeling remains that, irrespective of how you run the code, you will probably need to define a variable that you can then use in a loop, possibly a For ... In ... Do ... that acts on a folder containing your source files to be processed.

Helmut originally created the NConvert support guides, so although your problem is not directly related to that notation, or may not be related, with his much greater experience with scripting NConvert, possibly he can provide some support? That will likely not be until much later in the day, though.
cday
XnThusiast
Posts: 3484
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Only executing one file then stopping

Post by cday »

@staylor43448:

If Helmut is unable to see the problem in your code, and you are able using your Excel output to create the full code line required for each conversion, you should be able to avoid the need to use a loop by creating a batch file with one conversion per line.
cday
XnThusiast
Posts: 3484
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Script only executing one file then stopping

Post by cday »

In the absence of a response so far from Helmut, I suspect after some investigation that the 'xxx' notation that I didn't recognise is
VBScript notation, which has in the past evidently to some extent been supported in XnView software. The following comments are based on my brief research.

VBScript would seem to have been for a long time a standard component in Windows, as a component in the Internet Explorer browser, and was no doubt so when Helmut wrote the wiki page. It has however long since been deprecated, although is still available and can be activated in even the latest versions of Windows.

If you are confident that the output you obtain from the first conversion is correct, then VBScript is presumably enabled on your computer, so the failure to run the second conversion in your script so far remains unexplained. If there is any doubt that it is enabled, you could search online for the way to enable it in your version of Windows, and then test again.

The alternative would be to simply create a batch file with each required conversion placed on a separate line.
staylor43448
Posts: 4
Joined: Wed Aug 10, 2022 10:21 am

Re: Script only executing one file then stopping

Post by staylor43448 »

Thanks for your input - the batch file suggestion seems to be a winner, don't know why I didn't think of that before

Have just knocked one up quick, simply calling nconvert [options] [file] time after time, and it works perfectly!

Thanks!