Page 1 of 1

How to do batch processing resize-rename-resize?

Posted: Tue Jul 06, 2010 4:13 pm
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?

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

Posted: Wed Jul 07, 2010 8:33 am
by xnview
Here you can use NConvert or XnViewMP

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

Posted: Wed Jul 07, 2010 11:05 pm
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?

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

Posted: Thu Jul 08, 2010 9:31 am
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

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

Posted: Thu Jul 08, 2010 1:46 pm
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!