Possible to use a variable in the -o value?

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

Moderators: XnTriq, xnview

Post Reply
johnp12
Posts: 1
Joined: Thu Mar 08, 2018 12:30 am

Possible to use a variable in the -o value?

Post by johnp12 » Thu Mar 08, 2018 12:39 am

Hi,

I am trying to add a variable to the output name so that my program can change as needed

The following works (hard coded -o value):

Code: Select all

system('C:\"Program Files (x86)"\XnView\nconvert -npcd 2 -size 256x256+0 -ctype rgb -corder inter -out jpeg -o C:\watermark\folderx\%%.jpg -wmfile "C:\Users\john\Downloads\TDL_Placeholder.jpg" -wmflag center -wmpos 10 10  "C:\tempdir\sat\game1\DSC_7303.JPG"')
The following sets it to some odd folder. ($gamefolder = "sat")

Error: Can't create file (C:\watermark\C:\tempdir\sat\game1\gamefolder\DSC_7303DSC_7303.jpg)

Code: Select all

system('C:\"Program Files (x86)"\XnView\nconvert -npcd 2 -size 256x256+0 -ctype rgb -corder inter -out jpeg -o C:\watermark\$gamefolder\%%.jpg -wmfile "C:\Users\john\Downloads\TDL_Placeholder.jpg" -wmflag center -wmpos 10 10  "C:\tempdir\sat\game1\DSC_7303.JPG"')
Any help is greatly appreciated.

cday
XnThusiast
Posts: 1843
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Possible to use a variable in the -o value?

Post by cday » Thu Mar 08, 2018 8:22 pm

If you are using NConvert on Windows, I think the following may provide a solution:

o Run your code in a batch file .bat ;

o Use cmd.exe ('DOS') to define a variable using SET first;

o Use the defined variable in the -o term.

From memory [I'm on holiday and using my out-of-the-house laptop] I think you need something like:

SET A=Your_desired_value [where 'A' is an arbitrary name]

Then use %A% to insert the desired value in the -o term.

I can't easily check whether NConvert will accept a variable, or check the SET format, but you can Google if you need more information. :wink:

Post Reply