Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

(by DOS I mean windows cmd.exe - I don't want to enforce powershell or similar on the end user)

I want to run a command line file that prints output to CON / the screen.

I want to capture that output and compare it to an expected output.

... in a .bat / .cmd file?

Specifically, the identify command of ImageMagick, and I want to run this over +- 300 files and compare the actual sizes to expected sizes.

example output:

$ identify rose.jpg

rose.jpg JPEG 640x480 sRGB 87kb 0.050u 0:01

share|improve this question
up vote 1 down vote accepted

If I understand the question correctly, you want to run the identify command on all the jpg files in a directory and capture the output of that command into a text file for later comparison. The comparison however is not part of the spec?

Something like the line below should do that job. Just run it from the folder the jpg files are located:

for /R %%X in (*.jpg) do identify %%X >> PicInfo.txt

This will capture the rose.jpg JPEG ... line for every .jpg file you have in the directory (and subdirectories thanks to '/R') that you run the command in and append it to the file PicInfo.txt.

share|improve this answer
thx - I knew a few ways to do the comparison, hence not part of the question. I'm not very familiar with "for", so thx for that and I'll do some research on its various switches. As for ">>" that is actually the key to this - with it I guess the solution is easy, but I didn't know it existed (only knew about ">") – Richard Le Mesurier Feb 23 '13 at 15:11
if you want, copy your answer to stackoverflow at…... I think it is a better answer than the current one. – Richard Le Mesurier Feb 23 '13 at 15:15

Your question is a little hard to understand.  I’ll assume that you did something like

@echo off
for %%X in (*.jpg) do (
    identify "%%X" > "otherdir\"

at some point in the past, thus creating files with names like, and now you want to verify that the JPEG files haven’t changed.  I suggest

@echo off
for %%X in (*.jpg) do (
    identify "%%X" > "tempdir\"
    fc "tempdir\" "otherdir\" > nul
    if errorlevel 1 (
        echo "tempdir\" and "otherdir\" differ.
    ) else (
        del "tempdir\"

fc is the Windows command line File Compare program.

share|improve this answer
+1 thx - answer given to mcalex because he answered forst, and for the ">>" append function. – Richard Le Mesurier Feb 23 '13 at 15:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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