Page 1 of 1

How to truncate Filename outputs?

Posted: 2012-03-01T16:45:54-07:00
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

Re: How to truncate Filename outputs?

Posted: 2012-03-01T20:01:00-07:00
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.

Re: How to truncate Filename outputs?

Posted: 2012-03-03T16:13:44-07:00
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?