0

A start of the line

identify -format %w input.jpg

in Command Prompt leads to printing of the width of the image.

I have to assign this value to some variable within a CMD-file in order to use this variable further in the script. How can I do this?

I need some code like this:

@echo OFF  
set width=identify -format %w input.jpg
rem ...further usage of %width%...

However, it doesn't work.

P.S.: The code presented in this answer is almost what I need, but I need a code for the CMD-script.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jordan
  • 585
  • 1
  • 7
  • 18
  • the code to grab the output depends on the output. – Endoro Sep 09 '13 at 06:11
  • When I start `identify -format %w input.jpg` from the command line, something like "1600" (I meen, just a number, an image width) on the next line is printed. I do not know, if this can help. – Jordan Sep 09 '13 at 15:13

1 Answers1

2

you might try this:

for /f %%a in ('identify -format %%w input.jpg') do set "width=%%~a"
echo %width%
Endoro
  • 37,015
  • 8
  • 50
  • 63