Substrings in bat files

Useful snippet of code for getting substrings in windows batch files:

Code:

SET VARIABLE=%OTHERVARIABLE:~index,length%

Example:

SET FIRSTNAME=%HELENNAME:~0,5%

Source: windows 2000 mailing list.

Posted on 27 Sep 04 by Helen Emerson (last updated on 27 Sep 04).
Filed under Sysadmin

Comments

Miksu 04 Nov 2008

A good thing that someone knew this. I used it to set up a task running every hour, in a sort of easy way.