I have a program that outputs a number of files, e.g. in1,in2,...in499,in500. I want to use IM to do the same thing to each of these files.
in1 --> out1
in2 --> out2
...
in500 -->out500
On windows 7, using IM 7.0.6, if I do magick in*.png -dosomething out%d.png, they come out in some odd order. I can do magick in%d.png[1-500] -dosomething out%d.png, which gives in1 --> out0, ..., as long as the input files are all in sequence. What I would like to do is magick in*.png -dosomething out%s.png, which could replace the '%s' with whatever is matched by the '*'. Any suggestions?
Output file globbing
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Output file globbing
There are a couple ways to approach this. The simplest method for specifying the order of the named output files is to modify your string formatting of the output file name something like this...jwes wrote: ↑2017-09-03T11:08:29-07:00On windows 7, using IM 7.0.6, if I do magick in*.png -dosomething out%d.png, they come out in some odd order. I can do magick in%d.png[1-500] -dosomething out%d.png, which gives in1 --> out0, ..., as long as the input files are all in sequence. What I would like to do is magick in*.png -dosomething out%s.png, which could replace the '%s' with whatever is matched by the '*'. Any suggestions?
Code: Select all
magick input*.png -resize 50% output%03d.png
Another angle would be to use the input file names to create the output file names. You can do something like this...
Code: Select all
magick input*.png -set filename: "out_%[t]" -resize 50% "%[filename:].png"
Find out more about using IM's formatting escapes at THIS link.
In a BAT script you'll have to make all those single percent signs "%" into doubles "%%".
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Output file globbing
Another possibility is to have one convert per input file, in a shell script loop that processes all in*.png files, and creates an output name something like:
Then if an infile is named in543.png, the outfile would be named out543.png.
Code: Select all
set outfile=%infile:in=out%
snibgo's IM pages: im.snibgo.com