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
Search found 2 matches
- 10 Sep 2025 04:01
- Forum: DOS Batch Forum
- Topic: to dir or not to dir
- Replies: 2
- Views: 10607
- 06 Jan 2024 02:11
- Forum: DOS Batch Forum
- Topic: to dir or not to dir
- Replies: 2
- Views: 10607
to dir or not to dir
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: %Dir?%"c:\windows" if %errorlevel%==0 (echo dir) else (echo file) it works through symbolic links(everything you can googl...