is there a way to display the list without the quotation marks when ampersands present?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 162
Joined: 26 Aug 2017 06:11

is there a way to display the list without the quotation marks when ampersands present?

#1 Post by nnnmmm » 14 Dec 2024 21:04

C:\F9-AA1.TXT has the content below
DIR /B /O *.* &REM EEEE
DIR /B /O /A-D *.* &REM no dirs when files
DIR /B !!*.*
DIR /B *.B*
DIR /B *.EXE
DIR
------------------------------------------
@ECHO OFF
SET K1=C:\F9-AA1.TXT
FOR /F "Delims=" %%V IN ('TYPE %K1%') DO (
CALL :Z-Delayed2 "%%V"
)
GOTO :EOF
:Z-Delayed2
SET "Sname=%~1"
SET "U=%Sname%"
SET H="%U%"
ECHO %H:~1,-1%
@EXIT /B

how can i display the list content without the quotation marks when there might be ampersands present? &REM remarks must be shown since they can explain the options to me.
*restrictions
1. hope to use CALL, because the strings from %%V will be heavily edited later (with FOR, IF, SET), this call structure is one i am going for at the moment
2. must NOT use SetLocal EnableExtensions EnableDelayedExpansion - i am done +20 years over flondering with EnableDelayed and "!" conflicts, i am removing all essential EnableDelayedExpansion from my batches but then i start to have a new problem with &. but i'd figure if & were not a real part of the batch operators for my use, then i might have a chance.

Sponge Belly
Posts: 232
Joined: 01 Oct 2012 13:32
Location: Ireland
Contact:

Re: is there a way to display the list without the quotation marks when ampersands present?

#2 Post by Sponge Belly » 18 Dec 2024 10:47

Hi nnnmmm,

Here’s an old trick I learnt from Jeb:

Code: Select all

for %%^" in ("") do echo(%%~"poison characters ! ^ & < | > without quotes%%~"
Read this SO Q&A for the full story.

Ho ho ho! :)

- SB

Post Reply