Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concatenation of variables in MSDOS 1

Status
Not open for further replies.

jcaulder

Programmer
Apr 22, 2002
241
US
Hi,

I hope this is a good forum to post this in. If not, please point me in the right direction.

I am trying to create a batch file using DOS only that concatenates two variables as in:

string1=WRK
string2=bo01
string3=string1 + string2

The result should be string3 = WRKbo01.

Is there any way to do this using only DOS commands?

TIA

J

 
I know that something like:

set string1=WRK
set string2=bo01
set string3=%string1%%string2%

will accomplish what I originally asked. However, specifically what I was trying to do was remove a substring of the variable. I have thought of some 'creative' ways to do this using a loop and writing out a new file because I don't think there is a way to do this using one script.

What I was actually trying to do was:

set string1=WRK
set string2=%clientname%

**insert code here to remove
first 3 letters of %string2%**

set clientname=%string1%%string2%

***********************************
So if initial %clientname%=CLNbo01 it would end up being:

clientname=WRKbo01

Probably no way to do this other than the creative way I've devised. Just thought it was worth asking.






 
I *think* the SET command might do what you want.

For example,the expression

SET foo=%bar:~1,6%


should set the variable foo to a substring of the variable bar starting at offset 1 (the second character) for six characters.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top