How to write a batch file called EX5.BAT
that lists all files matching any of the following criteria within the Windows folder and down through its sub directories?
Files with an extension starting with letter C.
Files without a file extension.
How to write a batch file called EX5.BAT
that lists all files matching any of the following criteria within the Windows folder and down through its sub directories?
Files with an extension starting with letter C.
Files without a file extension.
dir c:\windows\*. c:\windows\*.c /s/b/a-d
Easy:
pushd C:\Windows\
:: Part A
for /r %%a in (*.c*) do Echo %%~a
:: Part B
for /r %%a in (*) do if "%%~xa"=="" Echo %%~a
popd
setlocal enabledelayedexpansion
pushd C:\Windows\
for /r %%a in (*) do (
set var=%%~xa
if "!var!"=="" Echo %%~a
if "!var:~0,2!"==".c" Echo %%~a
)
popd
The latter method is obviously faster, but I posted the first one in case you wanted to do it individually as it is a lot cleaner.
I think I fond the Answer:
@echo off
rem a)
for /r c:\Windows %%X IN (*.C*) Do Echo %%X
pause
rem b)
for /r C:\Windows %%x IN (*.) Do echo %%x
pause