1.

Solve : Need help concatenating dos strings?

Answer»

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"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















Discussion

No Comment Found