motionman95 Posted March 17, 2009 Posted March 17, 2009 I'm trying to put multiple wildcards into the _FileListToArray function, but the way I'm doing it isn't working: _FileListToArray($FontDir, "*.ttf *.otf", 1) Basically, I'm just trying to make it look for files with .ttf or .otf extensions.
martin Posted March 17, 2009 Posted March 17, 2009 I'm trying to put multiple wildcards into the _FileListToArray function, but the way I'm doing it isn't working: _FileListToArray($FontDir, "*.ttf *.otf", 1) Basically, I'm just trying to make it look for files with .ttf or .otf extensions. If you look in File.au3 you will see that only one file type is allowed for, so you will have to use _FileListToArray twice and then combine the arrays returned. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Danny35d Posted March 18, 2009 Posted March 18, 2009 You can also use ? as a wildcard._FileListToArray($FontDir, "*.?tf", 1) AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Malkey Posted March 18, 2009 Posted March 18, 2009 If there are not any other files that fit the extension ".?tf" other than ".ttf" or ".otf", I would use Danny35d method. Here is an example of martin's method. That is, use _FileListToArray twice and combine the arrays returned. #include <File.au3> #include <Array.au3> $aArray = _FileListToArrayMultiSelect(@DesktopDir, "*.exe", "*.htm?", 1) ;$FontDir = "Directory Path" ;$aArray = _FileListToArrayMultiSelect($FontDir, "*.ttf", "*.otf", 1) _ArrayDisplay($aArray, "Files Selected") Func _FileListToArrayMultiSelect($dir, $search1, $search2, $iFlag = 0) Local $FileList, $FileList1, $Num, $Err = 0, $Err2 = 0 $FileList = _FileListToArray($dir, $search1, $iFlag) If @error > 0 Then $Err = 1 $FileList1 = _FileListToArray($dir, $search2, $iFlag) If @error > 0 Then $Err2 = 1 If ($Err2 = 1) And ($Err = 0) Then Return $FileList If ($Err2 = 0) And ($Err = 1) Then Return $FileList1 If ($Err2 = 0) And ($Err = 0) Then $Num = UBound($FileList) _ArrayConcatenate($FileList, $FileList1) $FileList[0] = $FileList[0] + $FileList[$Num] _ArrayDelete($FileList, $Num) Return $FileList EndIf MsgBox(0, "", "No Files\Folders Found.") EndFunc ;==>_FileListToArrayMultiSelect
motionman95 Posted March 18, 2009 Author Posted March 18, 2009 @Malkey and Martin: Thanks for the suggestion and the code! It works perfectly! *Does the happy dance*
martin Posted March 18, 2009 Posted March 18, 2009 (edited) @motionman95 - NP, but I'm glad Makley volunteered to do the hard work @Makey. That's a nice little function. If you had the $search parameter as a concatenated string and had the next parameter as the separator used then it could be used for any number of different file types. #include <File.au3> #include <Array.au3> $aArray = _FileListToArrayMultiSelect(@ScriptDir, "*.bmp;*.jpg;*.tff", ";", 1) Func _FileListToArrayMultiSelect($dir, $searchlist, $Separator, $iFlag = 0) Local $FileList[1] = [0], $Filelist1, $iN, $Num, $search $search = StringSplit($searchlist, $Separator) If $search[0] > 0 Then For $iN = 1 To $search[0] $Filelist1 = _FileListToArray($dir, $search[$iN], $iFlag) If Not @error Then $Num = UBound($FileList) _ArrayConcatenate($FileList, $Filelist1) $FileList[0] = $FileList[0] + $FileList[$Num] _ArrayDelete($FileList, $Num) EndIf Next EndIf Return $FileList;could be [0] EndFunc ;==>_FileListToArrayMultiSelect Edited March 18, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Malkey Posted March 18, 2009 Posted March 18, 2009 #include <File.au3> #include <Array.au3> $aArray = _FileListToArrayMultiSelect(@ScriptDir, "*.bmp;*.jpg;*.tff", ";", 1) Func _FileListToArrayMultiSelect($dir, $searchlist, $Separator, $iFlag = 0) Local $FileList[1] = [0], $Filelist1, $iN, $Num, $search $search = StringSplit($searchlist, $Separator) If $search[0] > 0 Then For $iN = 1 To $search[0] $Filelist1 = _FileListToArray($dir, $search[$iN], $iFlag) If Not @error Then $Num = UBound($FileList) _ArrayConcatenate($FileList, $Filelist1) $FileList[0] = $FileList[0] + $FileList[$Num] _ArrayDelete($FileList, $Num) EndIf Next EndIf Return $FileList;could be [0] EndFunc;==>_FileListToArrayMultiSelectmartin A much better function, more versatile, nicely done. Malkey
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