Page 1 of 1

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

Posted: 14 Dec 2024 21:04
by nnnmmm
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.

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

Posted: 18 Dec 2024 10:47
by Sponge Belly
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