Page 1 of 1

Saving all dimension information to a file

Posted: 2016-01-06T03:09:37-07:00
by Loikkanen
I want save all information of the dimensions of all jpg's in a directory (including sub-directories).

This seem to work: FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080

using standard output like this:
FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080 > \dimensions.txt
creates the file dimensions.txt each time as a new file.

and this creates a text file for each jpg, but the files are all across the sub-directories:
FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080 > %f.txt

Is there a parameter for sub-directories for identify?
Or any other suggestions?

Re: Saving all dimension information to a file

Posted: 2016-01-06T10:42:11-07:00
by fmw42
You will have to traverse your directory structure in your looping mechanism

Re: Saving all dimension information to a file

Posted: 2016-01-06T11:21:34-07:00
by GeeMack
Loikkanen wrote:I want save all information of the dimensions of all jpg's in a directory (including sub-directories).

This seem to work: FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080

using standard output like this:
FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080 > \dimensions.txt
creates the file dimensions.txt each time as a new file.
On Windows 7 64, and using IM7, this will make a single file containing all the file names and dimensions for all the JPGs in the directory "C:\your_directory\" and all its subdirectories.

Code: Select all

for /R C:\your_directory\ %I in ( *.jpg ) do identify -format "%f %wx%h\n" "%I" >> \dimensions.txt
It should work the same way on almost any version of Windows and with at least versions 6 and 7 of ImageMagick.

If you want the image file names in your output to include the full path, use "%i" instead of "%f" in your "identify" format string.

The drive and path you're searching needs to be in your "for" command right after the "/R" flag.

The output file, "dimensions.txt", will be created (or appended) in the root of the drive you run the command from, like "C:\dimensions.txt". You can, of course, specify any other location and file name.

You need to use the double redirect ">>" in order to append each new line of information to the file. Using just one ">" like you had in your command will overwrite the file each time the loop runs and leave only the last line of data in the file.

Make sure you clear that data file or delete it before you run the command again if you don't want to continue adding to it.

If you put the commands in a batch file, use two percent signs "%%" everywhere you use one "%" on the command line.

Re: Saving all dimension information to a file

Posted: 2016-01-07T09:02:29-07:00
by Loikkanen
Thank you. That worked.
It seems that you can omit the directory, so you can copy the cmd to another directory and use it as it is.

Code: Select all

for /R %%I in ( *.jpg ) do identify -format "%%i %%wx%%h\n" "%%I" >> \dimensions.txt