How to do batch processing resize-rename-resize?

Ask for help and post your question on how to use XnView Classic.

Moderators: helmut, XnTriq, xnview

Post Reply
Apple
Posts: 3
Joined: Tue Jul 06, 2010 3:31 pm

How to do batch processing resize-rename-resize?

Post by Apple »

Hello,

I've tried few image converters and XnView seems to be the most easy and completely tunable one! Good job!

I convert a lot of pictures at once.
1. resize to 800x600 to "results" folder;
2. rename result files (add "_800x600" to their filenames);
3. resize initial files to 150x150 to "results" folder;

I have saved settings for both resizes to two batch processing files.
But I couldn't add a rename operation to save it to batch processing file.

How do I create just one batch processing file to save the whole script to do all the job?
User avatar
xnview
Author of XnView
Posts: 46257
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: How to do batch processing resize-rename-resize?

Post by xnview »

Here you can use NConvert or XnViewMP
Pierre.
Apple
Posts: 3
Joined: Tue Jul 06, 2010 3:31 pm

Re: How to do batch processing resize-rename-resize?

Post by Apple »

Sorry, but I couldn't figure out how to do that with NConvert :(
I searched this forum but to no success.
I've read Usage.txt but sample codes didn't work for me

Could you please give me a working code for my case?
User avatar
xnview
Author of XnView
Posts: 46257
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: How to do batch processing resize-rename-resize?

Post by xnview »

For example:

Code: Select all

nconvert -ratio -rtype linear -resize 800 600 -out jpeg -o results/$_800x600 file.jpg
nconvert -ratio -rtype linear -resize 800 600 -out jpeg -o results/$ file.jpg
Pierre.
Apple
Posts: 3
Joined: Tue Jul 06, 2010 3:31 pm

FIXED: Re: How to do batch processing resize-rename-resize?

Post by Apple »

Thanks Pierre!

It worked from command line (I had to rearrange it a little, though):

Code: Select all

nconvert -ratio -rtype linear -resize 800 600 -out jpeg -o $results/%_800x600 file.jpg
But I still can't make it work as part of a batch file. It resizes to "results" folder but doesn't add "_800x600" suffix:

Code: Select all

@echo off 
 
:: create results folder
md results
 
:: go through a loop to process each *.jpg file with nconvert.exe 
for %%a in (*.jpg) do call :_resize %%a 
goto :eof 
 
:_resize 
set _f=%~nx1 
set _n=%~n1 

:: This line worked from command line: nconvert -ratio -rtype linear -resize 800 600 -out jpeg -o $results/%_800x600 file.jpg
nconvert -ratio -rtype lanczos -q 45 -resize 800 600 -out jpeg -o $results/%_n%_800x600.jpg %_f%

goto :eof 
 
:: end of file
:eof 
 
Could you please correct it so it added the "_800x600"?

UPD: I've found the problem. It was spaces after "set _f=%~nx1" and "set _n=%~n1"
After deleting those spaces everything started working just fine!
Thanks again!
Post Reply