Page 1 of 1

Help with using Identify in a Windows batch

Posted: 2015-01-20T13:16:05-07:00
by ChachiTron
Hello,

I'm a new IM user, and have a specific situation I can't seem to understand or resolve, despite doing my best to follow the instructions at:
http://www.imagemagick.org/Usage/window ... guidelines

I want to identify the width, height, and DPI for approximately 6,000 images in various directories, and write them out to individual text files. If it is any easier, writing them out to a single output file would be acceptable, so long as the file names are included in the output (they are all uniquely named).

These images are not the only images in those directories, and I do not want information from any other images in those directories. I'm pulling the file names of the images that I need out of a SQL database, and attempting to generating the appropriate IM commands from there.

If I take just one of the IM commands that I've generated out of SQL and paste it into the command prompt, I get the expected results, in the expected output file:

Code: Select all

identify -format "%d %f %w %h %x %y" "W:\SOURCEDIR\Image1.tif" > "C:\ImageSizes\Image1.txt"
Results in:

Code: Select all

W:\SOURCEDIR Image1.tif 7200 5029 200 200
But, when I try and throw all 6,000 of my paths into a single Windows .BAT file, like:

Code: Select all

identify -format "%d %f %w %h %x %y" "W:\SOURCEDIR\Image1.tif" > "C:\ImageSizes\Image1.txt"
identify -format "%d %f %w %h %x %y" "W:\SOURCEDIR2\Image2.tif" > "C:\ImageSizes\Image2.txt"
All of the output files read like:

Code: Select all

f h y
Clearly, I'm doing something wrong when generating my .BAT file... I hope this is a quick and easy answer for someone out there!

Thank you!
TJ

Re: Help with using Identify in a Windows batch

Posted: 2015-01-20T13:29:01-07:00
by snibgo
In a BAT file, % is the prefix for an argument: %0, %1, %2, etc. Other uses of % need to be doubled.

Code: Select all

identify -format "%%d %%f %%w %%h %%x %%y" "W:\SOURCEDIR\Image1.tif" > "C:\ImageSizes\Image1.txt"

Re: Help with using Identify in a Windows batch

Posted: 2015-01-20T13:34:42-07:00
by ChachiTron
That solved my issue, thank you very kindly!