Page 1 of 1
CMD NConvert All images in the catalog
Posted: Mon Mar 01, 2021 9:16 am
by NikolayHAOS1
Hello.
I use Google translate.
I ask for help.
The question is, for example, "resize the image on the long side" to 1024 pixels and rename it as ###.JPG with the removal of the source.
In the directory D:\222\ and all its subfolders.
What the command line code should look like using NConvert
Re: CMD NConvert All images in the catalog
Posted: Mon Mar 01, 2021 12:08 pm
by cday
NikolayHAOS1 wrote: Mon Mar 01, 2021 9:16 am
Hello, I use Google translate, I ask for help.
How to, for example, "resize the image on the long side" to 1024 pixels and rename it as ###.JPG with the removal of the source.
What the command line code should look like using NConvert?
Do you have a copy of the NConvert help file, copy for the current NConvert 7.70 attached.
In the directory D:\222\ and all its subfolders.
Using CMD I believe it is only possible to convert files in folders down one level...
If you need to convert files in folder more than one level down, that may be possible using Powershell?? or Linux??
If you need to convert files to a deeper level in a folder tree, have you considered using the GUI software XnConvert which I think can do that?
Re: CMD NConvert All images in the catalog
Posted: Mon Mar 01, 2021 1:33 pm
by NikolayHAOS1
The code below works with subfolders.
BUT does not assign a name to the file.
Tell me how to complete the code.
Code: Select all
@chcp 1251
FOR /f "delims=*" %%A IN ('dir *.jpg /b /s') do "D:\111\NConvert\nconvert" -ratio -rtype lanczos -resize longest 1024 -o $ -q 80 -opthuff "%%A"
Re: CMD NConvert All images in the catalog
Posted: Mon Mar 01, 2021 2:04 pm
by cday
Code: Select all
-o filename : Output filename
Use # to specify position of numeric enumerator
Use % to specify source filename
Use $ to specify full source pathname
Use $$ to specify source folder name
Use $EXIF:DateModified[date format] to specify EXIF date modified
Use $EXIF:DateTaken[date format] to specify EXIF date taken
Date format: Please check documentation of strftime
So try
-out jpeg -o %.jpg
Or more generally
-out jpeg -o name###.jpg for example.
The
-out jpeg term is possibly not needed for JPEG source files.
In a batch file .bat it is necessary to double
% to
%% to escape the character.
[Edited]
Re: CMD NConvert All images in the catalog
Posted: Tue Mar 02, 2021 5:11 am
by NikolayHAOS1
Code: Select all
@chcp 1251
@for /R D:\333\ %%A in (*.png *.jpg *.jpeg *.gif *.bmp) do "D:\111\NConvert\nconvert" -ratio -o $\### -out jpeg -rtype lanczos -resize longest 1024 -q 80 -opthuff "%%A"
Processes newly created files.
How to exclude this.
Re: CMD NConvert All images in the catalog
Posted: Tue Mar 02, 2021 7:09 am
by cday
NikolayHAOS1 wrote: Mon Mar 01, 2021 9:16 am
The question is, for example, "resize the image on the long side" to 1024 pixels and rename it as ###.JPG with the removal of the source.
NikolayHAOS1 wrote: Tue Mar 02, 2021 5:11 am
Code: Select all
@chcp 1251
@for /R D:\333\ %%A in (*.png *.jpg *.jpeg *.gif *.bmp) do "D:\111\NConvert\nconvert" -ratio -o $\### -out jpeg -rtype lanczos -resize longest 1024 -q 80 -opthuff "%%A"
Processes newly created files.
How to exclude this.
The source files can be removed using this option:
Is that what you mean?
Re: CMD NConvert All images in the catalog
Posted: Wed Mar 03, 2021 6:39 am
by NikolayHAOS1
They helped in the Russian forum. (
https://www.cyberforum.ru/soft-graphics)
Here is a completely correct working code.
Code: Select all
@for /f "delims= eol=" %%d in ('dir/ad/b/s D:\SITE') do @pushd "%%d"&@D:\SOFT\NConvert\nconvert.exe -quiet -ratio -o $\### -out jpeg -rtype lanczos -resize longest 1024 -q 80 -opthuff -D *.jfif *.jpg *.jpeg *.png *.gif *.bmp
Re: CMD NConvert All images in the catalog
Posted: Wed Mar 03, 2021 7:42 am
by cday
Thank you for posting your final code, it may help someone else one day...

Re: CMD NConvert All images in the catalog
Posted: Mon Mar 08, 2021 2:23 pm
by anfvan6
Я схожую необходимость решил следующим решением:
@Echo Off
SetLocal EnableDelayedExpansion
Set DataRoot="%1"
Set OutFile=out.txt
chcp 1251 > nul
For /F "delims=" %%A In ('Dir "%DataRoot%\" /B /A-D 2^>nul') Do (Echo %%~fA>>"%OutFile%")
For /F "delims=" %%A In ('Dir "%DataRoot%\" /S /B /AD') Do (
Set RelativePath=%%A
Set RelativePath=!RelativePath:%DataRoot%=!
For /F "delims=" %%B In ('Dir "%%~A" /B /A-D 2^>nul') Do (Echo !RelativePath!\%%~B>>"%OutFile%")
)
"C:\XnView\nconvert.exe" -out jpeg -ratio -rflag decr -resize longest 1024 -rtype lanczos -rmeta -overwrite -q 75 -opthuff -dct 3 -smoothingf 0 -subsampling 0 -l out.txt
del out.txt
два цикла в батнике формируют список файлов out.txt, которые следует преобразовать.
Этот батник я запускаю с панели Total Commander c параметром "%P" - это имя папки в которой нужно преобразовать все файлы включая в подпапках. Т.е. без тотала можно запустить бат с ключом названием папки типа "C:\XnView\"
Re: CMD NConvert All images in the catalog
Posted: Mon Mar 08, 2021 3:08 pm
by cday
anfvan6 wrote: Mon Mar 08, 2021 2:23 pm
Я схожую необходимость решил следующим решением:
I solved a similar need with the following solution:
Thank you, that may help someone in the future...
I rarely use more than very basic CMD myself as my needs are limited, CMD is now rather old, very cryptic for more than basic use, and not well documented for easy reference for more complex use!