1

How to I get details of images from all folders and sub folders with ImageMagick in this format.

file-name file-location file-format size width height

PS - I have read this page http://www.imagemagick.org/script/escape.php but cannot find how to get file location path and how to include files in sub folders .

0

I'm pretty sure ImageMagick won't work recursively like that by itself. You'll need to write a script/program around it to work through your directory structure and call it once per file you want to check.

  • Ok . What about getting the file location ? Do you know how to do that ? I searched for recursive image scripts but found only for Linux . I am on Windows . – Renuka Oct 30 '14 at 6:48
  • Search for something like "windows command prompt list files recursively" and you'll find plenty of information. – Reticulated Spline Oct 30 '14 at 17:03
0

The following command will return the information you are looking for:

  identify -format "%f %d %m %b %w %h\n" ./* ./*/*
  1. The escape sequence for the file directory is %d.
  2. To include all files in the current folder, use ./* (the shell wildcard).
  3. To include all files in all sub folders, use ./*/* (shell wildcards).

(You didn't tell which operating system you are on. The above will work for Linux, Unix and Mac OS X. For Windows, use .\*.* and .\*.*\*.* as wild cards.)

Attention!, if you have non-image files or PDF documents in your folders, this command could run for quite a long time. Non-image files will produce an error message like

identify: no decode delegate for this image format `EXE' @ error/constitute.c/ReadImage/501.

This can be avoided by re-directing all error messages to /dev/null.

So it may be better to use this variant:

 identify                                   \
   -format "%f %d %m %b %w %h\n"            \
    *.{jpg,jpeg,JPG,png,tif,tiff,ppm,gif}   \
    */*.{jpg,JPG,jpeg,png,tif,tiff,ppm,gif} \
   2>/dev/null

Here is an example from Mac OS X:

delta.jpg #12649876 JPEG 17441B 307 205
CMYK_separation_–_maximum_black.jpg #21270389 JPEG 1453360B 1600 4780
HFnCz.jpg #21270389 JPEG 356748B 1600 1195
combined.jpg #21270389 JPEG 528221B 1600 1195
res.jpg #26408022 JPEG 57546B 603 300
red-500x2000.jpg #26951336 JPEG 6288B 500 2000
resized-red-2000x2000.jpg #26951336 JPEG 7430B 1000 1000
big-edge-25.jpg #27290574 JPEG 98916B 1024 288
big.jpg #27290574 JPEG 19216B 1024 576
double.jpg #27290574 JPEG 35076B 480 270
small.jpg #27290574 JPEG 20716B 720 404

(Yes, I did run this command in a directory which has subdirectories named #27290574, #26951336 and similar....)

You may want to get the output look more table-like. For this, pipe the results through column -t. Try this then:

 identify                                   \
   -format "%f %d %m %b %w %h\n"            \
    *.{jpg,jpeg,JPG,png,tif,tiff,ppm,gif}   \
    */*.{jpg,JPG,jpeg,png,tif,tiff,ppm,gif} \
   2>/dev/null  |  column -t

Result in my case:

delta.jpg                            #12649876  JPEG  17441B    307   205
CMYK_separation_–_maximum_black.jpg  #21270389  JPEG  1453360B  1600  4780
HFnCz.jpg                            #21270389  JPEG  356748B   1600  1195
combined.jpg                         #21270389  JPEG  528221B   1600  1195
res.jpg                              #26408022  JPEG  57546B    603   300
red-500x2000.jpg                     #26951336  JPEG  6288B     500   2000
resized-red-2000x2000.jpg            #26951336  JPEG  7430B     1000  1000
big-edge-25.jpg                      #27290574  JPEG  98916B    1024  288
big.jpg                              #27290574  JPEG  19216B    1024  576
double.jpg                           #27290574  JPEG  35076B    480   270
small.jpg                            #27290574  JPEG  20716B    720   404

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.