Overwrite images with original extensions

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
keljnr
Posts: 11
Joined: 2018-10-16T03:29:47-07:00
Authentication code: 1152

Overwrite images with original extensions

Post by keljnr »

Hi, I have the following script that applies a color profile to any type of image, and then resave's as a jpg using original file name (overwriting the file):

Code: Select all

convert *.* -profile c:\LUTS\sRGB-IEC61966-2.1.icc -set filename:base "%[basename]" "%[filename:base].jpg"
Is there a way I can convert to the original file extension, instead of .jpg.
So if original file was a tif, it overwrites as a tif.

Windows 7
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Overwrite images with original extensions

Post by snibgo »

For escapes, see http://www.imagemagick.org/script/escape.php . Perhaps %[extension] would help.
snibgo's IM pages: im.snibgo.com
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Overwrite images with original extensions

Post by 246246 »

%f is whole filename. Just replace %[basename] to %f and remove the last ".jpg" at your command.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Overwrite images with original extensions

Post by snibgo »

Yes, %f is a better and more obvious idea than mine.
snibgo's IM pages: im.snibgo.com
Post Reply