NConvert : batch rename with step counting

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

Moderators: XnTriq, helmut, xnview

pedronac
Posts: 10
Joined: Mon Feb 29, 2016 12:49 pm

NConvert : batch rename with step counting

Post by pedronac »

hi,

I'm seting up a batch file for nconvert (http://newsgroup.xnview.com/viewtopic.p ... 83#p130483).
But I'm missing some thing with the names of out put files.
I tried the -n command, without success.

Can someone help me to rename files with a step of 24 ?

The standard output is like :
000.png
001.png
002.png
...
023.png

I need to be :
001.png
025.png
049.png
...

what would be the command line ?
Mixer
Banned
Posts: 166
Joined: Fri Aug 28, 2015 6:24 am

Re: Nconvert : batch rename with step counting

Post by Mixer »

If this is not classified information, could you please post current batch file code?
pedronac
Posts: 10
Joined: Mon Feb 29, 2016 12:49 pm

Re: Nconvert : batch rename with step counting

Post by pedronac »

Hello Mixer,

It is not classified.
For instance there is 2 lines of code.
nconvert -dither -grey 256 -crop 42 250 945 200 -out png -xall -dpi 250 -o test-cropped test.pdf
nconvert -n 1 573 24

The first converts all pages of pdf to png with 256 gray, dpi at 250, crop file and name to test-cropped
The seconde tries to rename with numbering sequence explained on my post :
from
000.png
001.png
002.png
...
023.png

to :
001.png
025.png
049.png
...

What is wrong ?
cday
XnThusiast
Posts: 4178
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Nconvert : batch rename with step counting

Post by cday »

The second line of your code lacks an input term: if the PNG files created by the first line are in the same folder as the batch file you could try:

Code: Select all

nconvert -dither -grey 256 -crop 42 250 945 200 -out png -xall -dpi 250 -o test-cropped test.pdf
nconvert -n 1 573 24 *.png
I would expect the folder after the batch file is run to contain both the input and output PNGs, so you might want to include a -D term to delete the input PNDs after they have been processed...

EDIT:

I'm not familiar with -n and the above code doesn't produce the desired result, I'm not sure whether it can be used to renumber files...

Always use wildcards with caution, though, and always test with copies of files, one small step at a time... :wink:

I normally prefer to place the input files in a separate folder, and usually output to a different folder, although that does complicate the code slightly and needs care in relation to spaces in paths, for example.

Edit:

An alternative approach to the original problem stated in the earlier post above might be to generate the required output file names directly when the original input file is are converted to PNGs, i.e. step counting rather than renaming the files initially created in a second operation.

One way that might be done is by creating a variable using cmd.exe ('DOS') SET that can be incremented, and then using that variable in the output term of the NConvert code to generate the required output file names directly when the code is run in a FOR loop; possibly Mixer can suggest how that could be implemented, or suggest an alternative solution?

Another possible approach would be to perform the renaming function using a command line renaming utility such as Bulk Rename Command and to include that operation in the batch file...
pedronac
Posts: 10
Joined: Mon Feb 29, 2016 12:49 pm

Re: NConvert : batch rename with step counting

Post by pedronac »

I ways use test files and save the originals for use when I'm 100% sure of the process.
I will try to add the -d option and the the BRC and keep you updated.
But I know that XNView has a rename function, that's why I was trying to find the good command.
pedronac
Posts: 10
Joined: Mon Feb 29, 2016 12:49 pm

Re: NConvert : batch rename with step counting

Post by pedronac »

-D command is welcome (it was looping before).
But the step function does not work.

I downloaded BRC.
It seems a very powerful tool.
But some how too complicated.

I searched some options using DOS.
But it requires some level of programming.
By the way, I fund that : http://superuser.com/questions/347931/h ... and-prompt
And this :

Code: Select all

@echo off
setlocal EnableDelayedExpansion
set i=0
for %%a in (*.jpg) do (
    set /a i+=1
    ren "%%a" "!i!.new"
)
ren *.new *.jpg
Files are first renamed with .new extension to avoid conflicts with the files being processed and then renamed back to .jpg at end.

Anyway, if I need to use a different tool, I prefer to use "batch rename" over XnView !
It does the job and it's simple.
That's why I was wondering if there is a command line to do it through NConvert.
In the other hand, I noticed that XnConvert to not have rename functions, so I can not create a script to be used on XnView...

The script .xbs file uses xml.
Someone know the tabs used to do renaming ?
Mixer
Banned
Posts: 166
Joined: Fri Aug 28, 2015 6:24 am

Re: NConvert : batch rename with step counting

Post by Mixer »

After trying nconvert with -xall option on .gif file (because I don't want to install ghostscript just to test it with .pdf) I think you have no control over the way this utlity numbers extracted frames. And if it was my probem, I'd rather used Advanced Renamer on output image files sequence to renumber them in any way I like, including numbering with step +24.
pedronac
Posts: 10
Joined: Mon Feb 29, 2016 12:49 pm

Re: NConvert : batch rename with step counting

Post by pedronac »

I did more tests using -n command.
Any combination of figures :
-n 1 553 24
-n 1 24 4
-n 4 4 4
...

Every line gives the same result : numering stating from 0 (test-0.png) until 23 (test-23.png).

You say the problem might come from -xall command ?
So if I convert the pdf to png I may not need to use -xall command in the same line of -n.
cday
XnThusiast
Posts: 4178
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: NConvert : batch rename with step counting

Post by cday »

Please see this new thread regarding the use of the NConvert -n option:

NConvert useage: option -n
pedronac
Posts: 10
Joined: Mon Feb 29, 2016 12:49 pm

Re: NConvert : batch rename with step counting

Post by pedronac »

thanks for that like cday.
I found a post that described a very similar problem.
Hopefully Pierre will see it :)