Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Need help concatenating dos strings  (Read 2183 times)

0 Members and 1 Guest are viewing this topic.

Sully145

  • Guest
Need help concatenating dos strings
« on: August 01, 2007, 02:26:25 PM »
I'm not sure the best way to contatenate two strings without the quotes displaying.  For example:

@echo off
SETLOCAL
:: Check command line parameters
SET DorQ=%1
IF NOT DEFINED DorQ   GOTO Syntax
echo input is %1
SET AString="\logfile.log"
echo will now string %DorQ% with %AString%
set fullpth=%DorQ%%AString%
echo %fullpth%

The output is:
C:\checkout>concat.bat "c:\csrDEVL"
input is "c:\DEVL"
will now string "c:\DEVL" with "\logfile.log"
"c:\DEVL""\logfile.log"

The result that I really want is:
"c:\DEVL\logfile.log"

contrex

  • Guest
Re: Need help concatenating dos strings
« Reply #1 on: August 02, 2007, 02:59:26 AM »
Two points...

1. Remove quotes from strings by using ~ modifier. If using passed parameter string, if %1 has quotes, %~1 is the same string without quotes. For example:

set DorQ=%~1

2. It is not necessary, in batch programming, when defining a string variable, to use quotes. (unless you actually want them to be part of the string). This is a difference from e.g. BASIC. So this is allowed:

SET AString=\logfile.log













« Last Edit: August 02, 2007, 10:35:02 AM by contrex »