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:
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.
Try this in a folder that only contains files:
Code:
@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.