Jump to content

_FileListToArray help!


Recommended Posts

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...