2

This has been frustrating me for TOO long. It can't be this hard. I've been looking at other people's examples and STILL cannot get two strings to match up in Batch. What am I doing wrong?

SET largeString="c:\programs\test"
SET compareTo="test"
SET smallString=%largeString:~13,4%
if %compareTo%==%smallString% echo YES

So that's literally ALL I'm trying to do. It will never echo YES. I have tried

if "%compareTo%"=="%smallString%"

And

if %compareTo% EQU %smallString%

And

if "%compareTo%" EQU "%smallString%"

I am so frustrated at this x.x Did I miss a space somewhere? Did I add a space somewhere?

1 Answer 1

3

Your quotations are a literal part of the largeString and compareTo strings, therefore your sub-string numbers are wrong and the quotations are included in the comparison from the compareTo string.

NOTE: OP updated answer, with new numbers.

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

1 Comment

Ah! I see. So I changed compareTo to equal just test (not "test") and the comparison worked. Thank you very much!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.