Sign in to follow this  
Followers 0
TuMiM

Search for multiple extensions

6 posts in this topic

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.")

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Why not just search AVI first and then search MOV?

Share this post


Link to post
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
Sign in to follow this  
Followers 0