How to truncate Filename outputs?

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
redkahuna
Posts: 9
Joined: 2012-03-01T00:32:56-07:00
Authentication code: 8675308

How to truncate Filename outputs?

Post by redkahuna »

I was wondering of there was a way to create a truncated output of converted files using mogrify?
ie:
/
image001--large.png
image002--large.png
image003--large.png

Code: Select all

mogrify -transparent none -resize 50% -define png:format=png32 *--large.png
This code only reduces and overwrites the *--large.png files

How can I get a result that keeps the original files and outputs the converted files by removing the last --large.png and get this below?
image001.png
image002.png
image003.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to truncate Filename outputs?

Post by anthony »

Their are ways to append some text to a filename (add "--large" for example),
See IM Examples, File Handling,Filename Percent Escapes
http://www.imagemagick.org/Usage/files/#save_escapes
but their are no string manipulation tools to extract a sub-string or modify strings (properities actually) within IM at this point.

Your best bet is to use some scripting solution...
IM Examples, Basics, Mogrify, Batch Processing Alternatives
http://www.imagemagick.org/Usage/basics/#mogrify_not

I have not even considered string manipulation for IMv7 properity handling, as I am having enough trouble figuring out how to add number formatting.
See notes on possible solutions in http://www.imagemagick.org/Usage/bugs/I ... tml#format
A few of these may be expanded to sub-string and RE modification, but really it is outside IM scope.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
redkahuna
Posts: 9
Joined: 2012-03-01T00:32:56-07:00
Authentication code: 8675308

Re: How to truncate Filename outputs?

Post by redkahuna »

anthony wrote: Your best bet is to use some scripting solution...
IM Examples, Basics, Mogrify, Batch Processing Alternatives
http://www.imagemagick.org/Usage/basics/#mogrify_not
I can't seem to find a way to do this in a DOS script.

Code: Select all

for %%a in ("*--large.png") do convert %%a -transparent none -resize 50%% PNG32:%%a (-truncate "%%a--large")?
Does anyone know of a way?
Post Reply