0

I can get image size with this code if I run direct cmd:

identify -format "%wx%h" E:\Image.jpg 

(the result = 640x480)

However, if I put this code in a bat file,

@echo off identify -format "%wx%h" E:\Image.jpg 

it doesn't work. so, (the result = h) ??

How can I do this. Thanks...

2
  • 2
    A script interprets %wx% as a (probably not defined) variable and replaces it with its value (probably nothing). The command line parser is slightly different: it keeps the literal %xw% when the variable is not defined. In a batch script. double the % to %% to escape them (treat them as a literal %): identify -format "%%wx%%h" E:\Image.jpg Commented Feb 5, 2023 at 12:58
  • 2
    in case, you are interested in the details, but be warned - it's hard stuff. Commented Feb 5, 2023 at 13:03

1 Answer 1

1

Switch % to %% in a Batchfile. Your code should be something like: identify -format "%wx%h" E:\Image.jpg

Sign up to request clarification or add additional context in comments.

2 Comments

Are you sure, you didn't forget to double them? ;)
Thank you so much. It works. By the way how can I set a value this result.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.