Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

(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

2 Answers 2

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 stackoverflow.com/questions/15024848/…... 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\%%X.id"
)

at some point in the past, thus creating files with names like rose.jpg.id, 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\%%X.id.tmp"
    fc "tempdir\%%X.id.tmp" "otherdir\%%X.id" > nul
    if errorlevel 1 (
        echo "tempdir\%%X.id.tmp" and "otherdir\%%X.id" differ.
    ) else (
        del "tempdir\%%X.id.tmp"
    )
)

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

 
discard

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.