Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

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
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"
) >> info.txt
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .