Jump to content

Search for multiple extensions


Recommended Posts

I have a script that currently looks for a file with an AVI extension and if not there sends a msgbox. I need it to look for t=files with an AVI or MOV extensions. How would i do that?

$AviSearch = FileFindFirstFile($path1 & "\*.avi")

If $AviSearch = -1 Then

GUICtrlSetData( $status, "AVI does not exist")

$return = MsgBox(1, "AVI File Does NOT Exist", "No AVI file is available in this directory.")

Link to comment
Share on other sites

Something like this?

#include <File.au3>

Local $ValidList
Local $Path = @DesktopDir & "\"
Local $List = _FileListToArray($Path)

For $i = 1 To $List[0]
    If _IsValidFile($Path & $List[$i]) Then
        $ValidList &= $Path & $List[$i] & @CRLF
    EndIf
Next

MsgBox(0, "", $ValidList)

Func _IsValidFile($sFile)
    If StringRight($sFile, 3) = "avi" Or StringRight($sFile, 3) = "mov" Then Return True
EndFunc

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Something like this?

#include <File.au3>

Local $ValidList
Local $Path = @DesktopDir & "\"
Local $List = _FileListToArray($Path)

For $i = 1 To $List[0]
    If _IsValidFile($Path & $List[$i]) Then
        $ValidList &= $Path & $List[$i] & @CRLF
    EndIf
Next

MsgBox(0, "", $ValidList)

Func _IsValidFile($sFile)
    If StringRight($sFile, 3) = "avi" Or StringRight($sFile, 3) = "mov" Then Return True
EndFunc

Seems like it would work but overly complicated? I was hoping for something a little more simple but I guess if it works i could go with it
Link to comment
Share on other sites

#include <File.au3>

Local $ValidList
Local $Path = @DesktopDir & "\"
Local $List = _FileListToArray($Path)

For $i = 1 To $List[0]
    If StringRight($Path, 3) = "avi" Or StringRight($Path, 3) = "mov" Then
        $ValidList &= $Path & $List[$i] & @CRLF
    EndIf
Next

MsgBox(0, "", $ValidList)

:mellow:

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

A little simpler:

#include <File.au3>
#include <Array.au3>

Local $sPath = @DesktopDir & "\"
Local $aList = _FileListToArray($sPath, "*", 1) ; 1 = files only

For $i = $aList[0] To 1 Step -1
    If (StringRight($aList[$i], 4) <> ".avi") And (StringRight($aList[$i], 4) <> ".mov") Then _ArrayDelete($aList, $i)
Next
$aList[0] = UBound($aList) -1
_ArrayDisplay($aList, "AVI or MOV files")

:mellow:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...