-1

space

@echo on &setlocal
    setlocal enableDelayedExpansion
    If "%computername%" == "DTCVDI-V33-0951" (
      SET NS=\\xx
       SET OPSDIR=!NS!\ProAdmin
       SET COGDIR=!NS!\CREM  
     )
    set "list=%COGDIR%\Config\Copy_Daily_EMTS_Reporting.txt"
    echo %list%
    pause

Here the list shows \\xx\CREM \Config\Copy_Daily_EMTS_Reporting.txt.

Why this space shows and how to remove this?

Stephan
  • 53,940
  • 10
  • 58
  • 91
Lalatendu Bag
  • 11
  • 1
  • 3

1 Answers1

2

because you told it to do so. Your line

SET COGDIR=!NS!\CREM  

has two spaces at the end, which are also assigned to the variable.

A better syntax is:

  SET "COGDIR=!NS!\CREM"  

The quotes prevent unintended spaces.

Stephan
  • 53,940
  • 10
  • 58
  • 91