China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-15 10:36
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to use FOR /F under pure DOS? View 1,824 Replies 1
Original Poster Posted 2010-05-23 22:53 ·  中国 重庆 联通
新手上路
Credits 6
Posts 2
Joined 2006-12-18 02:05
19-year member
UID 73835
Gender Male
Status Offline
What I mean is to find files of a specified type.
I don't know much about BAT. After reading BAT for a few days, I just wrote the following bit.
But I found that under pure DOS, FOR /F and such can't be used... Please experts come up with a solution.



@ECHO OFF & SETLOCAL ENABLEDELAYEDEXPANSION

::::::::::::::::::::::::::::::::::::::::::
::Suffix type definition, ","
SET FileTypes=*.gh0,*.sys,*.gho,*.max,*.bak
::Number of types
SET TypeCount=5

::::::::::::::::::::::::::::::::::::::::::
::Each type is defined to be 5 characters long
SET /A COUNT=(%TypeCount%)*5
::Get each extension and compare with dir result
FOR /F "usebackq skip=5 tokens=3,* delims= " %%a IN (`dir /a-D !FileTypes!`) DO (
::ECHO %%a----%%b----*%%~xb
FOR /L %%i IN (0 6 %Count%) DO (
IF "*%%~xb"=="!FileTypes:~%%i,5!" (ECHO Found file "%%b".)
)
)

:TOGHOST

PAUSE
Floor 2 Posted 2010-05-31 17:36 ·  中国 河北 唐山 中移铁通
新手上路
Credits 16
Posts 10
Joined 2005-10-26 13:08
20-year member
UID 44089
Gender Male
Status Offline
The /F parameter is not supported by the FOR command under pure DOS
Forum Jump: