[Solved] Output file enumeration with a multipage source

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

Moderators: XnTriq, xnview

pfreeman
Posts: 3
Joined: Sat Oct 01, 2016 5:53 pm

[Solved] Output file enumeration with a multipage source

Postby pfreeman » Sat Oct 01, 2016 9:12 pm

I am using nconvert to convert a multipage PDF to individual JPG files for later processing.
This works very well, but there is one small thing I would like to figure out how to fix. Output filenames are enumerated as 'output-0.jpg' ... 'output-9.jpg', 'output-10'.jpg etc.
Is there any way to force leading zeros, so that files are 'output-00.jpg' ... 'output-09.jpg', 'output-10'.jpg etc.?

If I use "-o %##" the enumeration is applied to the main file, so I get 'output01-0.jpg', 'output01-1.jpg'...'output-0-10.jpg' etc.

xnconvert can do this with "{filename}##" for output name, but I can't seem to duplicate in nconvert (and I don't understand the output for nconvert option, it always gives me blank files).

This is a minor issue, but it does make sorting by filename in later processing a wee bit more difficult, and if I am missing something obvious I'd be very grateful for a shove in the right direction!

Thank you!

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

Re: Output file enumeration with a multipage source

Postby cday » Sat Oct 01, 2016 9:55 pm

I don't know if this helps -- I've had a glass of wine before going to bed -- but this code run in a Windows batch file possibly produces the result you need:

Code: Select all

nconvert -xall -dpi 300 -out jpeg -o "%%-###.jpg" Filename.pdf

The output files created are:

Filename-001.jpg
Filename-002.jpg
Filename-003.jpg
Filename-004.jpg

Note that the '%' for the source filename is doubled because I'm testing in a batch file.

pfreeman
Posts: 3
Joined: Sat Oct 01, 2016 5:53 pm

Re: Output file enumeration with a multipage source

Postby pfreeman » Wed Oct 05, 2016 10:19 pm

I really appreciate you taking the time to reply here.

Unfortunately this is not doing what we hope. Instead I am getting files named
Filename-001-1.jpg, Filename-001-2.jpg, ... Filename-001-10.jpg, etc.

What am I doing wrong?

<addendum> The line in my batch file is:
nconvert -xall -dpi 300 -out jpeg -o "%%-###.jpeg" "%~1"

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

Re: Output file enumeration with a multipage source

Postby cday » Thu Oct 06, 2016 6:58 am

pfreeman wrote:<addendum> The line in my batch file is:
nconvert -xall -dpi 300 -out jpeg -o "%%-###.jpeg" "%~1"

If you are running the code in a batch file, does the '%' in '%~1' need to be doubled to escape the character, as in "%%-###.jpeg" ?

Code: Select all

nconvert -xall -dpi 300 -out jpeg  -o "%%-###.jpeg" "%%~1"

I don't immediately know, I never expected to use the command line... :wink:

If you test the code in my previous post do you get the desired file numbering?

pfreeman
Posts: 3
Joined: Sat Oct 01, 2016 5:53 pm

Re: Output file enumeration with a multipage source

Postby pfreeman » Thu Oct 06, 2016 7:29 am

The "%~1" in the batch file is replaced with the file name used as a parameter in calling the batch file, which is what I want. This replacement of "%" codes is why you need to double it if you want an actual % in the batch file. So in this case it is correct. I've checked that by typing directly from the command line with a real file name (using your code) and I get the same behavior -- the number for every file is the same, plus the -1,-2, etc.

I did find one possible factor... I am using an older version of nconvert and this may be a past behavior (or even bug). However when I tried updating nconvert just now to test this the program refused to run at all... so I damaged something.

I'm back to the old version for now (it is very late, I have to start teaching early tomorrow, any further messing with program installations is going to result in one of those xkcd upgrade scenarios where the best that can be hoped for is that the flood waters will put out the fire before the house burns to the ground...

If you have any idea why nconvert would suddenly decide it can't understand pdf files (because they aren't jpegs it seems) I'd appreciate the insight. It says "my error exit...<not a jpeg file: starts with 0x25 0x50>"

Any further thoughts on the numbering would also be much valued!

Thanks again!!

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

Re: Output file enumeration with a multipage source

Postby cday » Thu Oct 06, 2016 7:35 am

Deleted as no longer relevant.

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

Re: Output file enumeration with a multipage source

Postby cday » Thu Oct 06, 2016 11:25 am

I am now able to confirm that the problem seems to related to different output filenames being produced by different NConvert versions, and have started a new thread Different NConvert versions output different filenames as a separate bug report for maximum clarity.

If you need to post again, please post in your existing thread unless you can add new information that is directly relevant to the new thread.

Old versions of XnView software can be downloaded from this link, I used NConvert 6.05.

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

Re: Output file enumeration with a multipage source

Postby cday » Wed Oct 12, 2016 8:14 am

This issue has now been resolved with the release of NConvert 6.93 (October 11 2016/20:18:09) which is currently available in the XnView [Classic] 2.37 Extended download...


Return to “NConvert”

Who is online

Users browsing this forum: No registered users and 1 guest