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.

i have a folder containing images and i want to determine its Compression method used. So i would loop through the folder and do a grep Compression like this

and note i have installed grep for windows

for %f in (*.jpg) do  identify -verbose "%f" | grep Compression >> info.txt

However i need to write the file name and compression technique used so i modified the above command

for %f in (*.jpg) do  identify -verbose "%f" | grep Compression & echo "%f" & echo: >> info.txt

But the problem is that i get a blank txt file. Could someone pleas help me.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Redirection always applies to a single command – echo: >> info.txt, in this case – not to the entire command line.

You will need to group commands using ( )'s:

for %f in (*.jpg) do (identify -verbose "%~f" | grep Compression & echo "%~f" & echo:) >> info.txt

or in a more readable form,

for %f in (*.jpg) do (
    identify -verbose "%~f" | grep Compression
    echo "%~f"
    echo:
) >> info.txt
share|improve this answer

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.