Jackson Borneman
Jackson Borneman

Reputation: 11

Removing a variable number of characters from front of a string in batch

I am trying to remove a changing number of characters from a string right now I have it as set /A VAR=%VAR:~%Num%% is there any way you can think to make this work. I am currently trying to it with a goto loop so I can still reference the variable If you want to look at my code in context you can look at it on github at thumbdown.camojackson.com

Upvotes: 0

Views: 874

Answers (1)

Squashman
Squashman

Reputation: 14290

Well without seeing all your code I can give you some options.

For starters you do not use the /A option to do string manipulation.

1) Use delayed expansion.

set VAR=!VAR:~%Num%!

2) Use the CALL command to get an extra phase of expansion

CALL set VAR=%%VAR:~%Num%%%

Upvotes: 1

Related Questions