Jump to content

Searching for File Type


Recommended Posts

I am trying to write a script that involves finding a file that may have different names but the same file extension. What would be the best way to do this? I need to be able to take the path of the file, file name and extension included, and send it out to a text box.

Thanks for the help in advance

Link to comment
Share on other sites

Use FileFindFirstFile() and FileFindNextFile():

$bleh = FileFindFirstFile("*.bat")
If $bleh = -1 Then
    MsgBox(0, "Error", "File/folder not found")
    Exit
EndIf

While 1
    $file = FileFindNextFile($bleh)
    If @error Then ExitLoop
   
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($bleh)
[font="Impact"]Cats rule, humans drool.[/font]
Link to comment
Share on other sites

Use FileFindFirstFile() and FileFindNextFile():

$bleh = FileFindFirstFile("*.bat")
If $bleh = -1 Then
    MsgBox(0, "Error", "File/folder not found")
    Exit
EndIf

While 1
    $file = FileFindNextFile($bleh)
    If @error Then ExitLoop
   
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($bleh)

Awesome, thanks for the help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...