Page 1 of 1

batch convert a folder full of .jpg files to .jp2

Posted: 2014-10-07T19:22:25-07:00
by RCinSTP
I have a folder full of .jpg files that I would like to convert to .jp2 (jpeg 2000)
I tried a batch file like below but it's not working. I run the batch file in the same folder with the .jpg image files. Any help would be greatly appreciated.
===========================================

SETLOCAL EnableDelayedExpansion
SET CONVERT="%PROGRAMFILES%\ImageMagick\Convert"
...
for %%b in (*.jpg) do convert JP2: %%b %%~nb.jp2

Re: batch convert a folder full of .jpg files to .jp2

Posted: 2014-10-07T20:11:14-07:00
by snibgo
convert JP2: %%b %%~nb.jp2
That isn't valid convert syntax. The following is:

Code: Select all

convert %%b %%~nb.jp2

Re: batch convert a folder full of .jpg files to .jp2

Posted: 2014-10-15T09:17:13-07:00
by jaffamuffin

Code: Select all

@echo off
SETLOCAL
SET workdir=%~0
FOR /F %%A IN ('dir %workdir%\*.jpg /B /ON /A-D') DO (
  convert "%workdir%\%%A" "%workdir%\%%~nA.jp2"
)