iTechThereforeIam

_FileListToArray help!

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now