to dir or not to dir

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
BABUT
Posts: 2
Joined: 06 Jan 2024 02:01

to dir or not to dir

#1 Post by BABUT » 06 Jan 2024 02:11

Code: Select all

set Dir?=for /l %%# in (1 1 2) do if %%#==2 (for /f "tokens=*" %%# in (!in!) do if not "%%~a#"=="d----------" color 11) else setlocal enabledelayedexpansion ^& set in=
example:

Code: Select all

%Dir?%"c:\windows"
if %errorlevel%==0 (echo dir) else (echo file)
it works through symbolic links(everything you can google doesn't work)

miskox
Posts: 670
Joined: 28 Jun 2010 03:46

Re: to dir or not to dir

#2 Post by miskox » 06 Jan 2024 13:26

2B OR NOT 2B=FF

Saso

BABUT
Posts: 2
Joined: 06 Jan 2024 02:01

Re: to dir or not to dir

#3 Post by BABUT » 10 Sep 2025 04:01

some improvement for the case when enabledelayedexpansion is enabled globally(or not enabled- it doesn't matter):
set Dir?=for /l %%# in (1 1 2) do if %%#==2 (for /f "tokens=*" %%# in (^^!in^^!) do if not "%%~a#"=="d----------" color 11) else setlocal enabledelayedexpansion ^& set in=
ps: ^^!in^^! %D

Post Reply