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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
RCinSTP
Posts: 21
Joined: 2014-08-18T07:42:44-07:00
Authentication code: 6789

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

convert JP2: %%b %%~nb.jp2
That isn't valid convert syntax. The following is:

Code: Select all

convert %%b %%~nb.jp2
snibgo's IM pages: im.snibgo.com
jaffamuffin
Posts: 59
Joined: 2009-01-30T03:46:08-07:00

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

Post 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"
)

Post Reply