0

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.

1 Answer 1

2

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

You must log in to answer this question.

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