1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ECHOing the _CWD with a & in the path

Discussion in 'Support' started by Charles G, Dec 7, 2015.

  1. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,012
    Likes Received:
    0
    I have EmailAddr.btm which is attached and it's causing output for example:

    Code:
    In: C:\Program Files (x86)\Cyberlink\WaveEditor\web
    ====
    In: C:\Program Files (x86)\DoubleKiller Pro
    ====
    In: C:\Program Files (x86)\Eltima Software
    ====
    In: C:\Program Files (x86)\Eltima Software\SWF
    
    OnError.btm: Not a valid command. You may edit it or
    press ENTER to abort it.
    
    FLV Player
    
    [C:\]dir /a: "C:\Program Files (x86)\Eltima Software\SWF*"
    
    Volume in drive C is Win7_Galloway   Serial number is aea6:a855
    Directory of  C:\Program Files (x86)\Eltima Software\SWF*
    
    3/28/2013   1:35         <DIR>    SWF & FLV Player
                       0 bytes in 0 files and 1 dir
         308,934,520,832 bytes free
    
    [C:\]dir /a: /f "C:\Program Files (x86)\Eltima Software\SWF*"
    C:\Program Files (x86)\Eltima Software\SWF & FLV Player
    
    [C:\]
    This is being caused by :

    setdos /x-5
    echo In: %_CWD
    setdos /x+5

    Is there a simplier way to echo a string that might include the "&" char?
     

    Attached Files:

  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    Quote it: ECHO "%_CWD"
     
  3. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,012
    Likes Received:
    0
    @vince,

    But I don't want the " to appear in the output.

    Echo %@unquotes["%_CWD"] seems too much for a simple thing.....
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    Here's another way:

    Code:
    setlocal
    setdos /c0xfffe
    echo %_cwd
    endlocal
    
    The argument to /C should be a character that will never appear in any filename. I picked 0xFFFE because, per the Unicode spec, it's officially Not Even A Character; other values would work.
     
  5. Alpengreis

    Joined:
    Jan 12, 2014
    Messages:
    228
    Likes Received:
    6
    You have to enclose them in back quotes ...

    ECHO `%_CWD`
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,877
    Likes Received:
    30
    Huh?
    Code:
    v:\> ECHO `%_CWD`
    %_CWD
     
  7. Alpengreis

    Joined:
    Jan 12, 2014
    Messages:
    228
    Likes Received:
    6
    Uhh, NONSENSE from me, SORRY!

    Works for "direct" echo commands (messages) ...

    Code:
    [C:\]echo `test&test`
    test&test
    but not for functions or variables ...
     
  8. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    No worries; you're just giving the correct answer to a different question!
     

Share This Page