blindwig Posted March 14, 2006 Share Posted March 14, 2006 I was just looking at the _FileListToArray() function in the file.au3 library. It's author SolidSnake notes in the comments that it is just like "DIR /B". But what if you don't want "DIR /B"? What if you want all the details?Here is a new function:Func _FileListToArray2($s_Path=@MyDocumentsDir, $s_Mask='*') $h_Search = FileFindFirstFile($s_Path & '\' & $s_Mask) $s_FileName = FileFindNextFile($h_Search) If Not @error Then Dim $a_File[100][10] While Not @error $s_FullName = $s_Path & '\' & $s_FileName $a_File[0][0] += 1 If $a_File[0][0] >= UBound($a_File) Then ReDim $aFile[$a_File[0][0] * 2][10] EndIf $i_ExtMarker = StringInStr($s_FileName,'.',0,-1) If $i_ExtMarker Then $a_File[$a_File[0][0]][0] = StringLeft($s_FileName, $i_ExtMarker - 1) $a_File[$a_File[0][0]][1] = StringMid($s_FileName, $i_ExtMarker + 1) Else $a_File[$a_File[0][0]][0] = $s_FileName $a_File[$a_File[0][0]][1] = '' EndIf $a_File[$a_File[0][0]][2] = FileGetLongName($s_FullName) $a_File[$a_File[0][0]][3] = FileGetAttrib($s_FullName) $a_File[$a_File[0][0]][4] = FileGetSize($s_FullName) $a_File[$a_File[0][0]][5] = FileGetTime($s_FullName,0,1) $a_File[$a_File[0][0]][6] = FileGetTime($s_FullName,1,1) $a_File[$a_File[0][0]][7] = FileGetTime($s_FullName,2,1) $a_File[$a_File[0][0]][8] = FileGetVersion($s_FullName) $a_File[$a_File[0][0]][9] = FileGetShortName($s_FullName) $s_FileName = FileFindNextFile($h_Search) WEnd ReDim $a_File[$a_File[0][0] + 1][10] Return $a_File Else Return '' EndIf EndFuncWhich returns a 1-based 2-dimensioned array that looks like this:[0][0] = array size[x][0] = file name (w/o extension)[x][1] = file extension (w/o '.')[x][2] = long file name w/ full path[x][3] = file attributes[x][4] = file size[x][5] = file modification time[x][6] = file creation time[x][7] = file access time[x][8] = file version code[x][9] = short file name w/ full short pathSo to get a list of files and sort them by their modification date:$a_FileList = _FileListToArray2();default folder is My Documents _ArraySort($a_FileList, 1, 1, $a_FileList[0][0], 10, 5); sort decending by modification date _ArrayBox($a_FileList);display 2-d arrayAnd _ArrayBox() is function I wrote to help display large 2-d arrays. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
busysignal Posted March 20, 2006 Share Posted March 20, 2006 @ blindwig, nice work. I will incorporate it into one of my script and try it out.. Cheers.. Link to comment Share on other sites More sharing options...
cppman Posted March 21, 2006 Share Posted March 21, 2006 Nice! This will come in handy.... Good Job Miva OS Project 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