Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to merge variables in a batch file?

Featured Replies

Hello,

I have the following batch file:

SET %one% = "test"

SET %two% = "program"

Now I want %three% to contain somethign like this:

SomeWordstestprogram

That means that I want to have a string, attach %one% and then %two% to it and then write it into %three%.

How is that possible?

I tried PHP syntax but that didn't work ;)


  • Author

Hello,

This worked:

SET three = "SomeWord" + %one% + %two%

However, when I want to see whats in %three%, I don't get anything.

echo %three%

gives me

"echo is turned ON"

or something like that (it's a German Windows, so I had to translate it).

What am I doing wrong?

i found THIS for you

i never worked with batch commands but looking at some examples, i think you should try like this:

SET one = string1

SET two = string2

SET three = "some other string " + one + " " + two

ECHO %three%

You've got the wrong syntax for SET.

The correct syntax is: SET variable=string

SET one=test
SET two=program
SET three=SomeWord%one%%two%

echo %one%
echo %two%
echo %three%

Edited by [deXter]

set three = someword%one%%two%

echo %three%

leave no spaces and exclude "+" between %one% and %two%.

Edit: dexter beat me to it.

Edited by spacesurfer

  • Author

Thanks for the link, this finally worked:

SET THREE = SomeWords%one%%two%

SET THREE

The second line is used instead of the echo command.

thank You very very much 'mormoloc' :thumbup

I was looking for a site like this

Edited by NaDer_GenKO

Good practice notes:

  • Set your variables local to the running batch session
  • To prevent the inclusion of unwanted whitespace in your variables, enclose them in parentheses (lines 3, 4, 5)

@Echo Off
Setlocal
(Set one=test)
(Set two=program)
(Set three=SomeWords%one%%two%)
Echo/%%three%%=%three%

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.