Luke
Luke

Reputation: 2486

Unusual statement in batch script

I am trying to read through a windows batch script and replicate its function in python. However, I have come across a statement I am not familiar with... Having little experience with batch myself.

set variable = %variable:~-2%

Can anyone explain to me what this means?

Upvotes: 0

Views: 59

Answers (1)

RB.
RB.

Reputation: 37172

This will take the last 2 characters from variable and assign the result to variable.

For example:

SET  A=12345
ECHO %A:~-2% 
REM  This will print out "45"

See the "Substrings" section here for reference, and more examples.

Upvotes: 3

Related Questions