Geeky Posted July 10, 2006 Posted July 10, 2006 I don't know if any of you knows Gmod ( a half-life 2 modification). But im working on a script that will make spawnmenus just by the press of a button, what i want it to do is to list all the filenames from a folder with the .mdl extension. Is there a way to make it list all files? I'll figure out the part with the .mdl myself. Is there already a function to do it? or do i have to make it in some other way?
cppman Posted July 10, 2006 Posted July 10, 2006 #include <file.au3> $avArray = _FileListToArray("directory/folder", "*.wild") check the help file for _FileListToArray. Miva OS Project
Geeky Posted July 10, 2006 Author Posted July 10, 2006 Can't find anything with _FileListToArray, only _FileREADtoArray. Is it because my helpfile is old, or?
Geeky Posted July 10, 2006 Author Posted July 10, 2006 Looked through the forums, and i found the function FileFindFirstFile, and the FIleFindNextFIle and i think im just gonna use that. Thanks for your help.
Boolen Posted July 10, 2006 Posted July 10, 2006 Use last beta version and look for help file from this beta
cppman Posted July 10, 2006 Posted July 10, 2006 ah. Yeah, those functions work too, im just used to _FileListToArray() and find it simpler too. yeah, it required beta. Miva OS Project
Geeky Posted July 10, 2006 Author Posted July 10, 2006 D'oh. I have Beta but i forgot to select the beta as my helpfile (put the helpfile in my startmemi shortcuts)
Daniel W. Posted July 10, 2006 Posted July 10, 2006 expandcollapse popup;=============================================================================== ; ; Description: lists all files and folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax: _FileList($sPath, $sFilter = "*", $iFlag = 0) ; Parameter(s): $sPath = Path to generate filelist for ; $iFlag = determines weather to return file or folders or both ; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $iFlag=0(Default) Return both files and folders ; $iFlag=1 Return files Only ; $iFlag=2 Return Folders Only ; ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $sFilter ; @Error=3 Invalid $iFlag ; ; Author(s): SolidSnake <MetalGearX91@Hotmail.com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; ; Special Thanks to Helge and Layer for help with the $iFlag update ;=============================================================================== Func _FileList($sPath, $sFilter = "*", $iFlag = 0) Local $hSearch, $sFile, $asFileList[1] If Not FileExists($sPath) Then SetError(1) Return "" EndIf If (StringInStr($sFilter, "\")) or (StringInStr($sFilter, "/")) or (StringInStr($sFilter, ":")) or (StringInStr($sFilter, ">")) or (StringInStr($sFilter, "<")) or (StringInStr($sFilter, "|")) or (StringStripWS($sFilter, 8)="") Then SetError(2) Return 0 EndIf If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then SetError(3) Return "" EndIf $asFileList[0] = 0 $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch=-1 then SetError(0) Return 0 EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If $iFlag = 1 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop EndIf If $iFlag = 2 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop EndIf If $sFile = "." Or $sFile = ".." Then ContinueLoop ReDim $asFileList[UBound($asFileList) + 1] $asFileList[0] = $asFileList[0] + 1 $asFileList[UBound($asFileList) - 1] = $sFile WEnd FileClose($hSearch) SetError(0) If $asFileList[0] = 0 Then Return "" Return $asFileList EndFunc ;==>_FileList Not done by me but there it is --------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]
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