iTechThereforeIam Posted January 30, 2015 Posted January 30, 2015 Hi All, I'm new to AutoIT and need some help. I wish to write a script that will create an array and store a list specific file extensions of files in a specific directory. The following achieves this, somewhat (taken directly from the _FileListToArray help example); #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> FindSPFs() Func FindSPFs() ; List all the SPF files in the ShadowProtect directory using the default parameters. Local $aFileList = _FileListToArray("F:\ShadowProtect\", "*.SPF") If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf ; Display the results returned by _FileListToArray. _ArrayDisplay($aFileList, "$aFileList") EndFunc ;==>FindSPFs MsgBox($MB_SYSTEMMODAL, "", "") The above creates a nice list of the files I wish to work with but what I'd like to do is add to the array and be able to query the specific data stored in cells. I wish to add both File Size and Creation Date in separate columns for each file listed, along side the file name. I am then going to do file comparisons and delete files according to conditions set elsewhere. Any pointers in the right direction would be greatly appreciated! Thanks
jdelaney Posted January 30, 2015 Posted January 30, 2015 (edited) redim, and add the data #include <Array.au3> #include <File.au3> $sFolder = "c:\test3" Local Enum $iArray_file, $iArray_size, $iArray_created, $iArray_ubound $a = _FileListToArray($sFolder,"*",1) Local $a2[UBound($a)][$iArray_ubound] $a2[0][0] = $a[0] For $i = 1 To UBound($a) - 1 $a2[$i][$iArray_file] = $a[$i] $a2[$i][$iArray_size] = FileGetSize($sFolder & "\" & $a[$i]) $a2[$i][$iArray_created] = StringRegExpReplace(FileGetTime($sFolder & "\" & $a[$i],1,1),"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})","$2/$3/$1 $4:$5:$6") Next $a = $a2 $a2 = "" _ArrayDisplay($a) Edited January 30, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Moderators Melba23 Posted January 30, 2015 Moderators Posted January 30, 2015 iTechThereforeIam,Take a look at the Beta _FileListToArrayRec I have posted here - that allows you to do it all at once. The 4th example is the one you need to examine. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
iTechThereforeIam Posted February 2, 2015 Author Posted February 2, 2015 Thank you jdelaney and Melba23 for your responses. After a quick look, I think the beta version may be easier to implement. I'll review it further when I have more time (I'm at work at the moment) and I'll post back with an update later.
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