Command-line use only - Question

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

Moderator: xnview

allkar
Posts: 4
Joined: Sun Jul 05, 2026 5:42 pm

Command-line use only - Question

Post by allkar »

Hello,
I am looking for a way to launch xnConvert (or xnView) via the command line using specific parameters to resize images. Everything works as expected via the graphical user interface, and saving settings to an .xbs file also works without issues. However, I want to launch the program from the command line—specifying the source and destination directories as well as the target size—without the program interface appearing. The process should run entirely as a batch job: no prompts, no queries, everything in the background. Even using parameters like "quiet" or "verbose" hasn't yielded the desired result; the program window always appears, requiring me to click a button.
Unfortunately, none of the scripts or batch commands I found in the forum are working as intended.
I am using a 64-bit version of Windows but want to run the batch job via the command line.
Is there a way to run the program entirely in the background using parameters for source, destination, and target size?
cday
XnThusiast
Posts: 4574
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Command-line use only - Question

Post by cday »

Although the XnConvert app can be launched from the command line, to achieve what you want you'll need to create an NConvert script and then run that... :D

At a detailed level, you should be able to export much of the code you'll need from XnConvert configured to run the same operations in the GUI, but input and output terms, at least, will as far as I know have to be added using the code defined in the NConvert help file.

Note: When I last looked, code exported from XnConvert contained many standard code terms that were actually unnecessary, so reference to the help file may be worthwhile.
allkar
Posts: 4
Joined: Sun Jul 05, 2026 5:42 pm

Re: Command-line use only - Question

Post by allkar »

Yes, thanks. I’ve already tried that.
I also adjusted the .xbs file created by the program accordingly. However, I can't find a way to tell the program which source directory to use for the images, and the program interface keeps appearing, requiring a button click for confirmation (for each image).
Example for batch:
@chcp 1251
@for /R "E:\camera_pics\2023\08\JPG\" %%I in (*.jp*) do "E:\Apps\XnConvert\xnconvert" -v -quiet -ratio -rtype lanczos -rflag decr -rflag orient -resize 500 500 -sharpen 50 -dpi 96 -q 70 -overwrite -rmeta -rexifthumb -o E:\camera_pics\2023\08\out\%%~nI %%I
The program interface appears here, and each image must be confirmed individually.

Example for xbs file:
<?xml version="1.0" encoding="UTF-8"?><XnView_script version="1.0" name="parameter-test2">
<Resize mode="0" width="1000" height="1000" unit="0" ratio="true" orientation="false" enlarge="0" resample="7" gamma_correct="false"/>
<Output folder="E:/camera_pics/2023/01/1000" filename="{Filename}" case="0" startIndex="1" format="JPEG">
<Options overwrite="1" orgDate="true" keepMeta="true" keepICC="true" keepFolder="false" keepParentFolder="false" keepExtension="true" delOrg="false" multipage="false" allPages="false" openExplorer="false" beep="true" openBrowser="false" clearItems="false"/>
<JPEG quality="90" progressive="false" optimizeHuffman="false" rebuildThumb="true" orgQuality="false" DCTMethod="0" subSampling="0" smoothFactor="0"/>
</Output>
</XnView_script>
Attempting to declare the input folder (not in the example code) isn't working.
The script works correctly when loaded into the program interface, but not when I use the command line.
allkar
Posts: 4
Joined: Sun Jul 05, 2026 5:42 pm

Re: Command-line use only - Question

Post by allkar »

I think I’ve pinpointed the problem (it was sitting right in front of the screen). I had tried using xnConvert for batch processing instead of nconvert. It seems to work with nconvert. I’m just looking for a few necessary parameters to get the results I want.
@cday - thanks for your post. :D
Last edited by allkar on Sun Jul 05, 2026 6:43 pm, edited 1 time in total.
cday
XnThusiast
Posts: 4574
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Command-line use only - Question

Post by cday »

The XnConvert command line options have been extended recently and I am not familiar with them, however my suggestion was to forget about using XnConvert directly, and to use code in a script run at the NConvert command line, directly or as a batch file.

That is the only way that I have ever worked, normally writing code directly from reference to the help file, although you could certainly use some code terms exported from XnConvert, for running in NConvert rather than as an .xbs file. Note that you create the NConvert help file for the version you are using yourself, as described by helmut early in the NConvert forum section.

My command line experience is limited, and I normally post as no one else does so, other than some limited support from Pierre. In addition, I am now in Linux with a strong aversion to booting into Windows!

It might be interesting if you could post your code... :?:
allkar
Posts: 4
Joined: Sun Jul 05, 2026 5:42 pm

Re: Command-line use only - Question

Post by allkar »

Once I get my desired implementation working, I'd be happy to do that. However, it might take 2-3 days until I'm completely satisfied with all the options and my own results.

I intend to call nconvert from software I developed myself (exclusively for private use to manage hundreds of thousands of my own images, the data for which is stored in an SQL database). This software takes a different approach than standard commercial tools.

Thanks again for the feedback, which distracted me from repeated failed attempts and forced me to think.