AutoIt FileFindFirstFile Function

Search for files, and directories with the FileFindFirstFile function.

2199 views

Edited: 2017-03-26 15:10

The AutoIt FileFindFirstFile function is used to search for files and directories.

The search string is not case sensitive.

The * wildcard means zero or more files, while the question mark ? means zero or one file. *.* will return a list of both files and directories. Wildcards can only be used in the filename, or the file extension parts.

Using a 3-char extension will match any files beginning with those 3 characters, but using 2-char extensions will only list files with exactly that. This means that you might want to filter the result further with regular expressions.

The below script will return all .au3 files in the same directory as the script it self, and then close the search handle using the FileClose function.

$search = FileFindFirstFile("*.au3")

While 1
    Local $file = FileFindNextFile($search)
    If @error Then ExitLoop

    MsgBox(4096, "File:", $file)
WEnd

FileClose($search)

Tell us what you think:

  1. How to declare and work with variables in AutoIt, as well as some background information.
  2. Everything you need to know about working with minimized windows.
  3. How to set the request headers when performing HTTP requests.
  4. This Tutorial will focus on post requests in AutoIt, using the Winhttprequest.5.1 object.
  5. How to use while, for, and do until loops, and how to loop through arrays and object in AutoIt.

More in: AutoIt Tutorials