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.
is there a way to display the list without the quotation marks when ampersands present?
Moderator: DosItHelp
-
- Posts: 233
- 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?
Hi nnnmmm,
Here’s an old trick I learnt from Jeb:
Read this SO Q&A for the full story.
Ho ho ho!
- SB
Here’s an old trick I learnt from Jeb:
Code: Select all
for %%^" in ("") do echo(%%~"poison characters ! ^ & < | > without quotes%%~"
Ho ho ho!

- SB
Re: is there a way to display the list without the quotation marks when ampersands present?
And I learned a new variant for the trick last month, now it's enough to use %%" instead of %%~".
It's possible to create a single FOR meta-variable that's empty.
Previously it was only possible to create empty meta variables after a leading meta variable with content.
Code: Select all
FOR /F "tokens=* delims=X" %%^" in ("X") do (
echo %%" Special characters &..|..^..<..>
echo %%" Event a closing bracket ) doesn't harm
)
Previously it was only possible to create empty meta variables after a leading meta variable with content.
Re: is there a way to display the list without the quotation marks when ampersands present?
sorry about late response, i didnt think i would get an answer, i kind of gave up.
at the moment, i kind of read some of other posts, it might take a while for me to grab them to make a proper response as to if i can incorporate them into my batch or not.
i tried a few ways... didnt work
@ECHO OFF
SET K1=C:\F9-AA1.TXT
FOR /F "tokens=* Delims=&" %%^" IN ('TYPE %K1%') DO (
CALL :Z-Delayed2 "%%^"
)
GOTO :EOF
:Z-Delayed2
SET "Sname=%~1"
SET "U=%Sname%"
SET H="%U%"
ECHO %%" %H:~1,-1%
@EXIT /B
at the moment, i kind of read some of other posts, it might take a while for me to grab them to make a proper response as to if i can incorporate them into my batch or not.
i tried a few ways... didnt work
@ECHO OFF
SET K1=C:\F9-AA1.TXT
FOR /F "tokens=* Delims=&" %%^" IN ('TYPE %K1%') DO (
CALL :Z-Delayed2 "%%^"
)
GOTO :EOF
:Z-Delayed2
SET "Sname=%~1"
SET "U=%Sname%"
SET H="%U%"
ECHO %%" %H:~1,-1%
@EXIT /B