Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
linuxteche
- Posts: 10
- Joined: 26 Nov 2017 03:17
#1
Post
by linuxteche » 07 Jun 2018 10:25
Hi,
I am trying to remove a double quotes from a URL but I am unable to remove it
I tried the following code and more things but I am not able to remove the double quotes from the url. Could you please help me on how to remove the double quotes from url.
Also the url is something like this and the same gets reflected in sample.out, this is the url that comes from an application
Code: Select all
"https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576"
The FreeText in the does not get the url without quotes. I want the FreeText (in bold) to have the url without quotes.
Code: Select all
@echo off &setlocal
setlocal enabledelayedexpansion
set "PPI=C:\PPI"
echo "%AnalysisDeepLink%" >> E:\sample.out
set "ADL=%AnalysisDeepLink%"
rem set ADL1=!ADL:~1,-1!
rem echo.%ADL1%
rem set ADL=%ADL:"=%
rem echo %ADL%
rem for /f "useback tokens=*" %%a in ('%ADL%') do set str=%%~a
rem echo.%ADL%
echo %ADL% >> E:\sample.out
"%PPI%\ppi.exe" -c "%PPI%\ppi4vce.conf" -e "Domain=dummy;OriginSeverity=MAJOR;[b]FreeText[/b]=%ADL%" -w "%PPI"
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 07 Jun 2018 14:15
All three of these work for me.
Code: Select all
@echo off
setlocal enabledelayedexpansion
set ADL="https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576"
set "ADL1=%ADL:~1,-1%"
echo !ADL1!
set "ADL1=%ADL:"=%"
echo !ADL1!
for %%G in (%ADL%) do set "ADL1=%%~G"
echo !ADL1!
output
Code: Select all
C:\BatchFiles\quotes>quotes.bat
https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576
https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576
https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576
-
linuxteche
- Posts: 10
- Joined: 26 Nov 2017 03:17
#3
Post
by linuxteche » 07 Jun 2018 19:34
Thanks for your reply Sqashman. I too get the same.
But this url comes from another application, so I refer to that url as
Code: Select all
echo "%AnalysisDeepLink%" >> E:\sample.out
I could see the output in the sample.out as the url with double quotes
So, when I try the other codes, I am expecting the the double quotes removed but its not happening. In fact the output from
is not even getting updated.
Code: Select all
set "ADL=%AnalysisDeepLink%"
set "ADL1=%ADL:~1,-1%"
echo !ADL1!
echo ADL1 >> E:\\sample.out
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 07 Jun 2018 20:06
Variable name is irrelevant. Still comes out the same for me.
Code: Select all
@echo off
setlocal enabledelayedexpansion
set AnalysisDeepLink="https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576"
set "ADL1=%AnalysisDeepLink:~1,-1%"
echo !ADL1!
set "ADL1=%AnalysisDeepLink:"=%"
echo !ADL1!
for %%G in (%AnalysisDeepLink%) do set "ADL1=%%~G"
echo !ADL1!
Output
Code: Select all
https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576
https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576
https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#5
Post
by penpen » 08 Jun 2018 02:58
You noticed the flaw you made?
(Missing '!'-characters.)
Squashman wrote: ↑07 Jun 2018 20:06
Code: Select all
for %%G in (%AnalysisDeepLink%) do set "ADL1=%%~G"
This line shouldn't work (because of the '?' character in the link - at least under my windows 10).
"test.bat":
Code: Select all
setlocal enabledelayedexpansion
set AnalysisDeepLink="https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576"
set "ADL1="
for %%G in (%AnalysisDeepLink%) do set "ADL1=%%~G"
echo !ADL1!
Result:
Code: Select all
Z:\>test
ECHO ist ausgeschaltet (OFF).
penpen
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#6
Post
by Squashman » 08 Jun 2018 07:17
I was using Windows 10 when I was testing my code last night.
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#7
Post
by penpen » 08 Jun 2018 07:30
You haven't reinitialized ADL1, so you are echoing an older value.
penpen
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#8
Post
by Squashman » 08 Jun 2018 08:52
penpen wrote: ↑08 Jun 2018 07:30
You haven't reinitialized ADL1, so you are echoing an older value.
penpen
You are correct. That needs to be changed to a `FOR /F`
Code: Select all
@echo off
setlocal enabledelayedexpansion
set AnalysisDeepLink="https://dummy.com:443/en.server/html/next/index.jsp?dl=dash&envId=00001&planId=0001&Monitoring=false&FilterId=01&Start=1527782791576&End=1528387591576"
set "ADL1="
set "ADL1=%AnalysisDeepLink:~1,-1%"
echo !ADL1!
set "ADL1="
set "ADL1=%AnalysisDeepLink:"=%"
echo !ADL1!
set "ADL1="
for /f "delims=" %%G in (%AnalysisDeepLink%) do set "ADL1=%%~G"
echo !ADL1!