• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

FINDFIRST behavior changed

Jan 4, 2017
When using %@FINDFIRST[...,d] to check whether or not there are any sub directories, the next call of FINDFIRST w/o specifying attrs won't find any regular files.

Try this in a folder that only contains files:

@echo off

echo first dir: %@FINDFIRST[*.*,d]
echo %@FINDCLOSE[] > NUL

rem seems findfirst with attr d will result in any upcomming findfirst also searching for attr d (tcc bug?)
rem echo %@FINDFIRST[*.*,-d] > NUL
rem echo %@FINDCLOSE[] > NUL

echo first anything: %@FINDFIRST[*.*]
echo %@FINDCLOSE[] > NUL
Expected result: Finds a file
Actual result: Doesn't find a file

A workaround is to do a %@FINDFIRST[*.*,-d] after checking for sub folders, but it has the disadvantage that the next FINDFIRST wouldn't find anything in a folder that only contains sub folders and no files.
Top Bottom