gius Posted January 4, 2015 Posted January 4, 2015 Hello everyone,I apologize for my English.I am developing a small applicationwith _ArrayAddLocal $aFileList = _FileListToArray (@DesktopCommonDir)Local $aFileList1 = _FileListToArray (@DocumentsCommonDir)Local $aFileList2 = _ArrayAdd ($aFileList, $aFileList1)_ArrayDisplay ($aFileList2)but is not nothing in _ArrayDisplay, why?Then, how I can see the file, the date of modification?FileGetTime ($aFileList, $ FT_MODIFIED, 1)andFileGetTime ($aFileList1, $ FT_MODIFIED, 1) Where I can add?Thanks for your help
jchd Posted January 4, 2015 Posted January 4, 2015 (edited) Read again help file over _ArrayDisplay _ArrayAdd, and you'll discover that it uses a ByRef first parameter and returns something distinct from what you expect it to. Yet my answer isn't quite right as Melba rightly stressed just now. I badly need a second coffee for the other eye... Edited January 4, 2015 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Moderators Melba23 Posted January 4, 2015 Moderators Posted January 4, 2015 gius,Welcome to the AutoIt forums. You need to concatenate the arrays. Here is an example which shows you how to do what you want:#include <Array.au3> #include <File.au3> Local $aFileList = _FileListToArray (@DesktopCommonDir) ; Add a column _ArrayColInsert($aFileList, 1) ; And loop through the elements to get the time stamp For $i = 1 To $aFileList[0][0] $aFileList[$i][1] = FileGetTime(@DesktopCommonDir & "\" & $aFileList[$i][0], $FT_MODIFIED, 1) Next ; Here is the result _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8) ; Now do the same for the other list Local $aFileList1 = _FileListToArray (@DocumentsCommonDir) ; Add a column _ArrayColInsert($aFileList1, 1) ; And loop through the elements to get the time stamp For $i = 1 To $aFileList1[0][0] $aFileList1[$i][1] = FileGetTime(@DocumentsCommonDir & "\" & $aFileList1[$i][0], $FT_MODIFIED, 1) Next ; Here is the result _ArrayDisplay($aFileList1, "@DocumentsCommonDir", Default, 8) ; Use concatenate to join arrays - note we do not concatenate the count from the second array _ArrayConcatenate ($aFileList, $aFileList1, 1) ; But we add it here $aFileList[0][0] += $aFileList1[0][0] ;And here you have the result _ArrayDisplay($aFileList, "Concatenated", Default, 8)Please ask if you have any questions. 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
gius Posted January 4, 2015 Author Posted January 4, 2015 (edited) Thank You Melba23, your commented code, it is really clear and very well explained.I have a small problem:if I insert address as a folder on the Desktop,example folder "Test"I have an error is no longer visible the last modificationLocal $aFileList = _FileListToArray (@DesktopDir "Test")$aFileList [$i] [1] = FileGetTime (@DesktopDir "Test" & $aFileList [$i] [0], $FT_MODIFIED, 1)where I am wrong? thanks again I apologize, I realized that I had not entered "" after the address of the folder "Test" Local $aFileList = _FileListToArray (@DesktopDir "Test")$aFileList [$i] [1] = FileGetTime (@DesktopDir "Test" & "" & $aFileList [$i] [0], $FT_MODIFIED, 1) Sorry and thanks again Edited January 4, 2015 by gius
mikell Posted January 4, 2015 Posted January 4, 2015 $aFileList [$i] [1] = FileGetTime (@DesktopDir "Test" & "" & $aFileList [$i] [0], $FT_MODIFIED, 1)
gius Posted January 5, 2015 Author Posted January 5, 2015 It is possible to change the date format of FileGetTime "YYYYMMDDHHMMSS"in "YYYY/MM/DD[HH:MM:SS]" of DateTimeFormat with $Type = 0 _DateTimeFormat(_NowCalc(), 0) ? thanks to all
water Posted January 5, 2015 Posted January 5, 2015 Sure. Please have a look at StringRegExpReplace or search the forum for "date formatting" or something similar. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
jguinch Posted January 5, 2015 Posted January 5, 2015 ; Method 1, with an array $aTime = FileGetTime (@ScriptFullPath) $sRes = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]" ConsoleWrite($sRes & @CRLF) ; Method 2, with string manipulation $sTime = FileGetTime (@ScriptFullPath, 0, 1) $sRes = StringRegExpReplace($sTime, "^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3[$4:$5:$6]") ConsoleWrite($sRes & @CRLF) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
gius Posted January 5, 2015 Author Posted January 5, 2015 Thank You jguinch and water for your help,but in this code #include <Array.au3> #include <File.au3> Local $aFileList = _FileListToArray (@DesktopCommonDir) ; Add a column _ArrayColInsert($aFileList, 1) ; And loop through the elements to get the time stamp For $i = 1 To $aFileList[0][0] $aFileList[$i][1] = FileGetTime(@DesktopCommonDir & "\Test" & "\" & $aFileList[$i][0], $FT_MODIFIED, 1) Next ; Here is the result _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8) I can not understand where to insert $sRes = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]" You can still help me?thank you
Moderators Melba23 Posted January 5, 2015 Moderators Posted January 5, 2015 gius,You need to do something like this: For $i = 1 To $aFileList[0][0] ; Get file timestamp as an array $aTime = FileGetTime(@DesktopCommonDir & "\Test\" & $aFileList[$i][0], $FT_MODIFIED) ; Format the array elements as required $aFileList[$i][1] = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]" NextM23 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
gius Posted January 5, 2015 Author Posted January 5, 2015 Thank You Melba23, I put your help #include <Array.au3> #include <File.au3> Local $aFileList = _FileListToArray (@DesktopCommonDir & "\Test\") ; Add a column _ArrayColInsert($aFileList, 1) ; And loop through the elements to get the time stamp For $i = 1 To $aFileList[0][0] ; Get file timestamp as an array $aTime = FileGetTime(@DesktopCommonDir & "\Test\" & $aFileList[$i][0], $FT_MODIFIED) ; Format the array elements as required $aFileList[$i][1] = $aTime[0] & "\" & $aTime[1] & "\" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]" Next _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8) but I returns this error: Subscript used on non-accessible variable.: For $i = 1 To $aFileList[0][0] For $i = 1 To $aFileList^ ERROR I have done something wrong? thank you
Moderators Melba23 Posted January 5, 2015 Moderators Posted January 5, 2015 gius,That would mean that the function has not found any files in the folder. So you need to add some errorchecking, perhaps like this: #include <Array.au3> #include <File.au3> Local $aFileList = _FileListToArray (@DesktopCommonDir & "\Test") If Not @error Then ; Add a column _ArrayColInsert($aFileList, 1) ; And loop through the elements to get the time stamp For $i = 1 To $aFileList[0][0] $aTime = FileGetTime(@DesktopCommonDir & "\Test" & "\" & $aFileList[$i][0], $FT_MODIFIED) $aFileList[$i][1] = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]" Next ; Here is the result _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8) Else MsgBox($MB_SYSTEMMODAL, "Error", "No files found") EndIfM23 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
gius Posted January 6, 2015 Author Posted January 6, 2015 Thank You Melba23,Your code works fine. I have tried to add a second column, $ FT_CREATED, #include <Array.au3> #include <File.au3> Local $aFileList = _FileListToArray (@DesktopCommonDir & "\Test") If Not @error Then ; Add a column _ArrayColInsert($aFileList, 2) ; And loop through the elements to get the time stamp For $i = 1 To $aFileList[0][0] $aTime = FileGetTime(@DesktopCommonDir & "\Test" & "\" & $aFileList[$i][0], $FT_MODIFIED,$FT_CREATED) $aFileList[$i][2] = $aTime[0] & "/" & $aTime[1] & "/" & $aTime[2] & "[" & $aTime[3] & ":" & $aTime[4] & ":" & $aTime[5] & "]" Next ; Here is the result _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8) Else MsgBox($MB_SYSTEMMODAL, "Error", "No files found") EndIf but I'm wrong in something, where? thank you
Moderators Melba23 Posted January 6, 2015 Moderators Posted January 6, 2015 gius,You need to read the Help file when you try to change function parameters - what you did made no sense at all when you look how the functions work. If you want another column with the created time you need to do something like this: #include <Array.au3> #include <File.au3> Local $sPath = @DesktopCommonDir & "\Test" Local $aFileList = _FileListToArray($sPath) If Not @error Then ; Add 2 columns <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _ArrayColInsert($aFileList, 1) _ArrayColInsert($aFileList, 2) ; And loop through the elements to get the different time stamps For $i = 1 To $aFileList[0][0] $sFile = $sPath & "\" & $aFileList[$i][0] $aTime_Mod = FileGetTime($sFile, $FT_MODIFIED) ; Modified time $aTime_Created = FileGetTime($sFile, $FT_CREATED) ; Created time ; Now add these values to the array $aFileList[$i][1] = $aTime_Mod[0] & "/" & $aTime_Mod[1] & "/" & $aTime_Mod[2] & "[" & $aTime_Mod[3] & ":" & $aTime_Mod[4] & ":" & $aTime_Mod[5] & "]" $aFileList[$i][2] = $aTime_Created[0] & "/" & $aTime_Created[1] & "/" & $aTime_Created[2] & "[" & $aTime_Created[3] & ":" & $aTime_Created[4] & ":" & $aTime_Created[5] & "]" Next ; Here is the result _ArrayDisplay($aFileList, "@DesktopCommonDir", Default, 8) Else MsgBox($MB_SYSTEMMODAL, "Error", "No files found") EndIfM23 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
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