Montage - Exclude Videos ?

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
sum_duud
Posts: 2
Joined: 2018-03-03T21:58:02-07:00
Authentication code: 1152

Montage - Exclude Videos ?

Post by sum_duud »

Good day, I am using Montage to create a Contact_Sheet.jpg in several direcrories, one contact sheet per directory. However some of the directories have small video files (.mp4 or .mpg) along with the JPG, TIFF, PNG and RAW files, is there a way to specifically exclude files such --exclude *,mpg ? or similar.

ImageMagick 7.0.7-22 Q16 x86_64 2018-01-13 for Mac OSX

Thanks in advance
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage - Exclude Videos ?

Post by fmw42 »

You can just list the formats you want. For example:

Code: Select all

magick montage *.jpg *.tif -tile x1 result.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage - Exclude Videos ?

Post by fmw42 »

This will exclude jpg from the directory

Code: Select all

magick montage $(ls | grep -v "\.jpg$") -tile x1 tmp.png
where i have use

ls | grep -v "\.jpg$"

to make a list of all files in the directory excluding .jpg

Search google and you will find other methods.
sum_duud
Posts: 2
Joined: 2018-03-03T21:58:02-07:00
Authentication code: 1152

Re: Montage - Exclude Videos ?

Post by sum_duud »

Excellent, thanks for the help guys this is great.
The excluding specific formats with Grep seems like a great way to go.
$(ls | grep -v "\.mpg$")
---
Sum Duud, Oz.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Montage - Exclude Videos ?

Post by GeeMack »

sum_duud wrote: 2018-03-04T14:32:42-07:00Excellent, thanks for the help guys this is great.
The excluding specific formats with Grep seems like a great way to go.
$(ls | grep -v "\.mpg$")
Also, most versions of "ls" will accept an "--ignore" option. To omit the MPGs from the listing, try something like this...

Code: Select all

ls --ignore "*.mpg"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage - Exclude Videos ?

Post by fmw42 »

That does not work on my Mac. I tried it.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Montage - Exclude Videos ?

Post by GeeMack »

fmw42 wrote: 2018-03-04T16:08:20-07:00That does not work on my Mac. I tried it.
At least on my installation the "ls" that comes with Windows 10 bash accepts that "--ignore" option. Maybe it's not as common as I thought.

I have an "ls" that comes as part of a GNU32 package and runs from the Windows command line. It takes an upper-case "-I" option. This ignores the "*.mpg" files...

Code: Select all

ls -I"*.mpg"
Given those variations, piping the output of "ls" through "grep" may be a better, more universal solution.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage - Exclude Videos ?

Post by fmw42 »

That option is not available on my Mac either. I checked that also earlier as per some Google searches. I think it because Mac is not using GNU unix. I have had trouble before with the Mac Unix not being as flexible as GNU.

P.S. Those were both good suggestions and I found them also by doing a Google search. But they just don't work on the Mac. So I generally try to use solutions that work on my Mac, since they generally also work in other Linux systems.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Montage - Exclude Videos ?

Post by snibgo »

"ls --include '*.mpg'" and "ls -I '*.mpg'" work fine on the ls that comes with Cygwin, on my Windows 8.1. It works both in bash, and from the Windows CMD prompt.
snibgo's IM pages: im.snibgo.com
Post Reply