Batch image editin: operating on files with prefix of...

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
leafpressed
Posts: 4
Joined: 2014-09-28T06:20:26-07:00
Authentication code: 6789

Batch image editin: operating on files with prefix of...

Post by leafpressed »

Hi, I just posted this post on batch processing: viewtopic.php?f=1&t=26321, and the advise was sound.

Now, before I put the images in their respective folders, I would like to operate on the whole folder, but only on all the images with a selected prefix.

Some of the files would be 18_14+4 and then _{num}.gif I would like to operate on all the images that have the first 7 characters in common, irrespective of the next three numbers.

So if I went: convert *.gif -resize 4500x516 *.gif, this would only be applicable for some of the images, but I don't want to separate them into folders yet to save time by operating on the larger folder first, first all the images, then various catagories, then separate into folders...

Thankyou for your help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch image editin: operating on files with prefix of...

Post by fmw42 »

convert *.gif -resize 4500x516 *.gif
This is not proper syntax for convert. I do not think you can have wild cards for both input and output in IM. If you are trying to get one output for each input image. then use mogrify. That is what it is meant to do.

Your question about filtering names is not an IM topic. I do not think IM can do that kind of thing. It is something you can do in your OS directly or by shell or bat scripting.
leafpressed
Posts: 4
Joined: 2014-09-28T06:20:26-07:00
Authentication code: 6789

Re: Batch image editin: operating on files with prefix of...

Post by leafpressed »

Thankyou for your reply.

As I understand it, convert can work on multiple files, that command just worked, resized all the images in the folder to what I wanted. What is the issue is that mogrify has less commands than it works with, and convert will do multiples with some commands, just not all.

So this way or that way, I welcome further replies on this topic. 8)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch image editin: operating on files with prefix of...

Post by fmw42 »

Look carefully at your files and the names.

When I create a folder, called test on my desktop (Mac OSX)
and put 3 files there (copies if logo:).

cd desktop/test
ls
logo1.png
logo2.png
logo3.png

Now do
convert *.png -resize 50% *.png
ls

logo1.png
logo2.png logo3-1.png
logo3.png

logo3-0.png
logo3-2.png
logo3-3.png
logo3-4.png

So I start with 3 images and end with 4 new images that are all from logo3.png

If you are on Window, perhaps your OS works different from unix.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Batch image editin: operating on files with prefix of...

Post by snibgo »

Some shells will expand wildcards, so might expand "*.gif" into a list of all filenames that match.

Windoze does this, as I discovered by accident. My own programs can take the argument "/?" for help. This worked fine until I had a file named "x" in my root directory. So Windows translated "/?" into "/x" before passing it to my program, which then did the correct action for the argument "/x", even though I had merely asked for help. It took me two weeks to figure out that this wasn't a bug in my software. Grrr.

I hate this "feature".
snibgo's IM pages: im.snibgo.com
Post Reply