FINDFIRST$ function

Purpose: Returns the first file in the current folder matching the filespec.


 Syntax:

 RetStr$ = FINDFIRST$(FileSpec$)

 Parameters:

  • RetStr$ Returned name of first file in the current folder matching the FileSpec$.
  • FileSpec$ String literal or variable containing file name.

Example: The following example will copy all the files from C:\Temp to C:\Temp\Junk.


 DIM F$
 F$ = FINDFIRST$("*.*")
 WHILE F$ > ""
   COPYFILE "C:\Temp\" + F$, "C:\Temp\Junk\" + F$
   F$ = FINDNEXT$
 WEND

Remarks: The F$ = FINDFIRST$("*.*") will return the file for the current folder, that is, the folder from which the application is being run. To enumerate the files in some other folder, either add a


 CHDIR "C:\SomeOtherFolder" 
 

or else use


 F$ = FINDFIRST$("C:\AnotherFolder\*.*").

BCX Console Sample Programs using FINDFIRST$ function.

S67.bas   S74.bas   S103.bas. Also see the Recursive File Find example on the Recursive functions page.


FINDNEXT$ function

Purpose: Returns the next file in the current folder matching the FINDFIRST$ filespec


 Syntax:

 RetStr$ = FINDNEXT$ 

 Parameters:

  • RetStr$ Returned name of next file in the current folder matching the FileSpec$.

BCX Console Sample Programs using FINDNEXT function S67.bas, S103.bas.
Also see the Recursive File Find example on the Recursive functions page.