Search code examples
regexgrepimagemagickposixposix-ere

RegEx syntax for ImageMagick "identify" within bash shell


I'm trying to run the ImageMagick identify command on a very large path of images where Identify returns the image dimensions of files that match a pattern. The pattern I'm trying to match is:

/jewelclub_[a-z0-9]{1,}_(small|medium|large|zoom)\.jpg/

When I try to execute the following two commands, the first succeeds and the second fails which seems like there must be something wrong with my RegExp:

(1): identify -format "%f %w %h %b \n" 'jewelclub_*\.jpg'
(2): identify -format "%f %w %h %b \n" 'jewelclub_[a-z0-9]{1,}_(small|medium|large|zoom)\.jpg'

Any advice on how to change my PCRE syntax in command #2 to a compatible RegEx flavor (BRE? ERE?)?

Thanks in advance for the help.


Solution

  • are you sure identify accepts a regexp as file argument ?

    how about this work-around, passing your regexp to find and then piping to xargs:

    find -E . -regex "./jewelclub_[a-z0-9]{1,}_(small|medium|large|zoom)\.jpg" |\
    xargs identify -format "%f %w %h %b \n"