TuMiM Posted May 26, 2010 Share Posted May 26, 2010 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 More sharing options...
AlmarM Posted May 26, 2010 Share Posted May 26, 2010 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 More sharing options...
TuMiM Posted May 26, 2010 Author Share Posted May 26, 2010 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 More sharing options...
AlmarM Posted May 26, 2010 Share Posted May 26, 2010 #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) 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 More sharing options...
PsaltyDS Posted May 26, 2010 Share Posted May 26, 2010 (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") Edited May 27, 2010 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 More sharing options...
Richard Robertson Posted May 26, 2010 Share Posted May 26, 2010 Why not just search AVI first and then search MOV? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now