getting my batch file to work

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

Moderators: XnTriq, helmut, xnview

Post Reply
unquestioned2
Posts: 20
Joined: Mon Apr 30, 2012 10:32 pm

getting my batch file to work

Post by unquestioned2 »

I have created a file "C:\AMD\batch.bat" which contains the following line:
"c:\Program Files (x86)\XnView\nconvert" -i C:\AMD\developed\*.jpg -o C:\AMD\sharpened\% -efocus

The folder "C:\AMD\developed\" contains one file "testfile.jpg".

If I open a command line and execute "batch.bat it NConvert creates a
"testfile_1.jpg" in the "C:\AMD\developed" folder instead of a
"testfile.jpg" in the "C:\AMD\sharpened\" folder
and gives me the following error messages:

Can't open file (-o)
Can't open file (C:\AMD\sharpened\)
Can't open file (-efocus)

Where is the problem?
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: getting my batch file to work

Post by cday »

I just posted a second reply to your original post asking about the command line, giving some very basic advice.

I don't know if it would help with this problem; I would start with the simplest possible test and work from there, unless someone can answer your detailed request here quickly.

Chris.
unquestioned2
Posts: 20
Joined: Mon Apr 30, 2012 10:32 pm

Re: getting my batch file to work

Post by unquestioned2 »

Thank you for your suggestions.

I have tried more than
"c:\Program Files (x86)\XnView\nconvert" -i C:\AMD\developed\*.jpg -o C:\AMD\sharpened\% -efocus
but with the same result.

In
http://newsgroup.xnview.com/viewtopic.php?f=57&t=3857
it's described
nconvert -i sample.gif -o tif
but this didn't work for me either.

It somehow doesn't understand one of the options.
And if someone's able to tell the correct form of the line in my first post,
this would help me definitly to understand what's going wrong.
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: getting my batch file to work

Post by cday »

Doesn't % need to be %% in a batch file?

Also, -i is shown in the documentation as 'interlaced GIF / Progressive JPG' and the simple example you refer to used a gif file. I think there is something wrong with your syntax.

I found exporting scripts from VnView useful, although it does seem to put in some overhead at the start which is confusing and probably isn't required.

I think the Notepad word-wrap issue I referred to in the other post would apply to any text editor; I would turn it off to be safe until someone can confirm or refute it.

Hopefully someone authoritative will post soon on your queries.

C.
unquestioned2
Posts: 20
Joined: Mon Apr 30, 2012 10:32 pm

Re: getting my batch file to work

Post by unquestioned2 »

%%? - Did not hear of that, but could be possible.

The -i argument irritated myself. I've read the documentation too (before I read your post) and found the same out as you did.
-i seems not to be "input file" as -o is "output file".

VnView? What's this? Do you have a link for that or is this simply a spelling error? - Doesn't matter. Somehow.

After all that -i thing is a very stupid example from my point of view because it's not generally useable.
How many people get the same error messages as I did and throw it away as i did?
unquestioned2
Posts: 20
Joined: Mon Apr 30, 2012 10:32 pm

Re: getting my batch file to work

Post by unquestioned2 »

At last I got it working. Here are the parameters:

"C:\Program Files (x86)\XnView\nconvert" -opthuff -q 97 -subsampling value2 -efocus -org_depth -o C:\AMD\sharpened\%% C:\AMD\developed\*.jpg

As you can see it was necessary to use %%. It's undocumented (not like $$) but it works. And the output file has to be mentioned before the input file (which wasn't introduced by -i).

The whole thing was a little bit annyoing. Thanks for your help. Unless last time I finally got it working. I will test the quality of the results and apply more parameters. At least the thing with the file names is now done. As you can see there is really a bug in the parameter handling -q 97 is divided by one space and subsampling value2 isn't. There is always room for improvement!
unquestioned2
Posts: 20
Joined: Mon Apr 30, 2012 10:32 pm

Re: getting my batch file to work

Post by unquestioned2 »

I finally got it working! (This time really.)

value2 for -subsampling is wrong. It's a simple 2. (We have to understand how the documentation is meant.)

The last parameters I've used are:
"C:\Program Files (x86)\XnView\nconvert" -opthuff -q 97 -subsampling 2 -efocus -soften 52 -org_depth -out jpeg -o C:\AMD\sharpened\%%.jpg C:\AMD\developed\*.*

So it's possible for me to use uncompressed 16-bit TIFF-images from Silkypix (as input).
Naturally it doesn't make much sense to sharpen something by software (because it lowers the quality in some other ways) but this seems to be an exception because my eyes prefer the sharpened photos even if they are from lower quality which I can see if I zoom into them to 300 percent or more.

The additional .jpg in %%.jpg has the reason that I use filenames like I-P1000841_01.05.2012,17'19.tif and NConvert is unable to understand what belongs to the date and what is the file extension. Without the additional .jpg in the parameters it creates jpeg-files without extensions (if the names of the input files are a little bit strange like mine).

I also created temporarely a help!.bat with the following command:
"C:\Program Files (x86)\XnView\nconvert" -help |more

It shows from anywhere the NConvert "documentation". (It's possible to leave it with CRTL+C (and to scroll it by pressing Space).)

The Notepad word-wrap issue you mentioned wasn't the problem in my case. Because I use Linux too and that can lead by exchanging files with Windows to problems too. So that's one of the first things I change in the Windows configurations if I install it new.
cday
XnThusiast
Posts: 3985
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: getting my batch file to work

Post by cday »

I’m glad you got there in the end!

Using NConvert does require poring over the documentation, persistence and lots of trial and error, as I said originally. The simple script from the documentation you tested wasn’t the best one to start with, there’s a better one somewhere that just converts a tiff to a jpeg, which would have helped you get nconvert running and find the correct syntax. I think exporting some very basic scripts from XnView batch processing would also have helped you.

The need to replace % by %% in batch files is documented somewhere, and I think arises when running batch files from within Windows. My learning curve was probably steeper than yours but I spent a lot of time searching the forum and using Google to get ideas and try to solve problems.

Using the command line with batch files does have some real advantages, and in some ways I’m amazed at what I have managed to do from a standing start, but it wasn’t easy…

C.
Post Reply