Page 1 of 1

to dir or not to dir

Posted: 06 Jan 2024 02:11
by BABUT

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)

Re: to dir or not to dir

Posted: 06 Jan 2024 13:26
by miskox
2B OR NOT 2B=FF

Saso

Re: to dir or not to dir

Posted: 10 Sep 2025 04:01
by BABUT
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