Symplystyc Posted December 22, 2008 Share Posted December 22, 2008 #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray(@ScriptDir) $sFile = @ScriptDir & "\Test.txt" If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf _FileWriteFromArray("test.txt", $FileList) Run("notepad.exe " & $sFile) What I would like to do is get a better grasp of autoit so I thought I'd start with some file sorting. At the moment I can get an array with all the files in a particular directory listed in it. What I would like to do now is sort those files in two different ways. One is alphabetically and the other is if there is a specific character(s) in the files name. If someone could point me in the right direction I'd appreciate it. The glass is neither half empty nor half full, it is simply twice as big as it needs to be. Link to comment Share on other sites More sharing options...
rasim Posted December 22, 2008 Share Posted December 22, 2008 #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray(@ScriptDir) $sFile = @ScriptDir & "\Test.txt" If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf _FileWriteFromArray("test.txt", $FileList) Run("notepad.exe " & $sFile) What I would like to do is get a better grasp of autoit so I thought I'd start with some file sorting. At the moment I can get an array with all the files in a particular directory listed in it. What I would like to do now is sort those files in two different ways. One is alphabetically and the other is if there is a specific character(s) in the files name. If someone could point me in the right direction I'd appreciate it. 1. _ArraySort function. 2. Example: #include <File.au3> #include <Array.au3> $aFileList = _FileListToArray(@ScriptDir) If @error Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf ;_ArraySort($aFileList, 1, 1) _ArraySortEx($aFileList, "txt") ;Sort by txt characters _ArrayDisplay($aFileList) Func _ArraySortEx(ByRef $array, $sPattern) Local $iUbound = UBound($array) Local $sTemp, $aTemp, $i For $i = 1 To $iUbound - 1 If StringInStr($array[$i], $sPattern) Then $sTemp &= $array[$i] & @LF $array[$i] = 0 EndIf Next For $i = 1 To $iUbound - 1 If $array[$i] Then $sTemp &= $array[$i] & @LF Next $array = StringSplit($sTemp, @LF) $array[0] = $array[0] - 1 ReDim $array[$array[0] + 1] EndFunc 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