Tsiyoshi Posted March 1, 2015 Posted March 1, 2015 Hi there! I am trying to modify a script (based on a script that I found in the forum - '?do=embed' frameborder='0' data-embedContent>>) that goes through a list of folders using _FileListToArrayRec, but when I try to retrieve the "modified date" of the folderd for my log, I keep getting a message: (27) : ==> Subscript used on non-accessible variable.: $sDate = $aDate[0] & "/" & $aDate[1] & "/" & $aDate[2] $sDate = $aDate^ ERROR I understand that there is an issue with retrieving the details from the array, but I can't quite figure out where my problem is. I Wonder if anyone can help me identify the problem? Thanks!! #include <Array.au3> #include <File.au3> #include <Date.au3> ; ***** Create local logs $log = FileOpen (@ScriptDir & "\masterlog.log",2+256) _FileWriteLog ($log,"*********************STARTING OPERATIONS*********************") ; put the root in a variable $sRoot = (@ScriptDir) ; Retrieve a list of all the folders in $sRoot, and store them as an array in $aList Global $aList = _FileListToArrayRec ($sRoot, "*", 2, 0) ; _FileListToArray("path" [, "Filter" [, Flag]]) ; Look at what _FileListToArray() puts into $aList _ArrayDisplay($aList) ; This is a loop that runs from 1 to the number of items listed in the first element of the returned array For $i = 1 To $aList[0] ; For each folder, get the modified date/time and store its individual parts in array $aDate $aDate = FileGetTime($sRoot & $aList[$i], 0, 0) ; FileGetTime("filename" [, option [, format]]) ; Look at what FileGetTime() puts into $aDate _ArrayDisplay($aDate) ; Build the properly formatted date string for _DateDiff()'s needs $sDate = $aDate[0] & "/" & $aDate[1] & "/" & $aDate[2] ;0 index stores the year, 1 index stores month, 2 index stores day ; Look at what we made into $sDate ;msgbox(0,"Check Output", $sDate) ; Use _DateDiff() to see if the difference is greater than 90 days, and if it's true, then delete (for now just log) the folder and all its subfolders If _DateDiff("D", $sDate, _NowCalcDate()) > 90 Then _FileWriteLog ($log,$sRoot & $aList[$i] & " " & $sDate, 1) Next _FileWriteLog ($log,"*********************Script Completed Successfully*********************")
Moderators Solution Melba23 Posted March 1, 2015 Moderators Solution Posted March 1, 2015 Tsiyoshi,@ScriptDir does not have a trailing " " so you need to add it yourself: $aDate = FileGetTime($sRoot & "\" & $aList[$i], 0, 0)M23 Tsiyoshi 1 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
Tsiyoshi Posted March 1, 2015 Author Posted March 1, 2015 Ah! I had a feeling it'll be something to do with the trailing just didn't know where. Thanks a lot Melba23!! I appreciate your help.
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