RDir

Result = RDir ( Directory AS String [ , Pattern AS String , Options AS Integer , FollowLink AS Boolean ] ) AS String[]

Return a string array that contains the names of files located in Directory and its sub-directories that match the Pattern.

The specified directory is recursed.

The pattern can contain the same generic characters as the LIKE operator. If no pattern is specified, any file name is returned.

The Options argument specifies what kind of files will be returned.

The filter can be one of the following values:
  • gb.File for returning only files.

  • gb.Directory for returning only directories.

  • gb.File + gb.Directory for returning both.

If Options is not specified, all files and directories are returned.

If FollowLink is TRUE, then symbolic links on directories are recursed. Otherwise they are processed like normal files.

The file paths returned are relative to the searched directory.

Since 3.20

If you add the gb.FullPath constant to the Options argument, the Directory path is added to each returned file.

Note that the pattern does not apply to the directory part in that case.

The pattern matches the full relative path, not just the file name.

So, if you wanted to find the file "/usr/share/icons/locolor/32x32/apps/libreoffice4.1-impress.png" in /usr, you must write:

RDir("/usr", "*libreoffice4.1-impress.png")

and not:

RDir("/usr", "libreoffice4.1-impress.png")

which will return nothing.

Example

' Print the png image files in a directory and its sub-directories

SUB PrintDirectory(Directory AS String)

  DIM File AS String

  FOR EACH File IN RDir(Directory, "*.png")
    PRINT File
  NEXT

END

See also