Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Pilou
- Posts: 6
- Joined: 07 Jan 2014 08:42
#1
Post
by Pilou » 06 Jul 2015 10:01
Hi,
I would like to know if it's possible to manage strings with at the same time & and | and " ? here is a snippet of my failed attemps :
Code: Select all
@echo off
setlocal enabledelayedexpansion
ver
echo ==============
set ONE=u "A&B" v
set TWO=ww %ONE% || xx
echo ONE=%ONE%
echo TWO=%TWO%
echo ==============
set ONE=u "A&B" v
set TWO=ww %ONE% ^|^| xx
echo ONE=%ONE%
echo TWO=%TWO%
echo ==============
set "ONE=u "A&B" v"
set "TWO=ww %ONE% || xx"
echo ONE=%ONE%
echo TWO=%TWO%
echo ==============
set "ONE=u "A^&B" v"
set "TWO=ww %ONE% || xx"
echo ONE=%ONE%
echo TWO=%TWO%
which gives :
Code: Select all
Microsoft Windows [Version 6.1.7601]
==============
ONE=u "A&B" v
TWO=ww u "A&B" v
==============
ONE=u "A&B" v
TWO=ww u "A&B" v
==============
'B" v"' is not recognized as an internal or external command,
operable program or batch file.
ONE=u
TWO=ww u
==============
'B" v || xx"' is not recognized as an internal or external command,
operable program or batch file.
ONE=u "A&B" v
TWO=ww u
Thanks a lot by advance
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 06 Jul 2015 10:49
Why have delayed expansion enabled if you are not going to use it.
-
Pilou
- Posts: 6
- Joined: 07 Jan 2014 08:42
#3
Post
by Pilou » 06 Jul 2015 11:19
Great ! replacing % by ! solves the problem indeed !
In fact, I just enable delayed expansion by reflex but I didn't know that it has also an effet outside a for loop
Big, big thanx
Last edited by
Pilou on 06 Jul 2015 11:51, edited 1 time in total.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#4
Post
by foxidrive » 06 Jul 2015 11:30
Pilou wrote:Great, repleacing % by ! solves the problem indeed !
Do you know what happens to ! characters?
-
Pilou
- Posts: 6
- Joined: 07 Jan 2014 08:42
#5
Post
by Pilou » 06 Jul 2015 11:52
foxidrive wrote:Pilou wrote:Great, repleacing % by ! solves the problem indeed !
Do you know what happens to ! characters?
Hum, no... I hope never get one in my data
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#6
Post
by foxidrive » 06 Jul 2015 11:56
Pilou wrote:Hum, no... I hope never get one in my data
Ok. It creates a mini blackhole in the vicinity of your batch file and they get gobbled up in the event horizon.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#7
Post
by Squashman » 06 Jul 2015 12:34
foxidrive wrote:Pilou wrote:Great, repleacing % by ! solves the problem indeed !
Do you know what happens to ! characters?
foxidrive (a.k.a Devils Advocate)
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#8
Post
by foxidrive » 06 Jul 2015 22:09
Squashman wrote:foxidrive (a.k.a Devils Advocate)
I'm married to his sister - it goes with the turf.