davdomin
davdomin

Reputation: 1219

How to compare string like start with in command Line

I Have this this folders:

And i need create and condition that compare those value but only a part of the string

for example if i have this variable directory and I can compare: something like this

IF (directory LIKE "91%")
   --------

But i dont know how to make this with Windows CommandLine.. Thanks

Upvotes: 1

Views: 907

Answers (1)

Stephan
Stephan

Reputation: 56208

ok, I'll try to guess, what you want to do:

You want to check if the value of a variable "directory" starts with a known string ("91")?

if "%directory:~0,2%"=="91"

%var:~0,2% takes two (2) chars from start (position 0)

Upvotes: 2

Related Questions