Haagimus Posted January 31, 2013 Share Posted January 31, 2013 Okay so here's the problem, myself and few of the 10 lb brains on this site developed a script that I was trying to create that would basically query my entire server, add all files into an array, query every file to check if it was created more than 14 days from current time, remove all entries older than 14 days from the array, then finally output all the remaining files into a text file with the creation date attached. This script is beautiful and worked like a charm, until my server had a HDD failure and general WHS failure. Since I have rebuilt and reformatted the system and placed all backup up files back into the server the script no longer works as advertised. I get the following error and will post the code below. New Files TXT output.au3 (21) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $FilteredFiles[$FilteredFiles[0][0] + 1][0] = $Time[2] & StringUpper(_DateToMonth($Time[1], 1)) & $Time[0] ^ ERROR and here is the code itself: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Comment=Thanks to Melba23 for helping with the multi dimensional array issues #AutoIt3Wrapper_Res_Description=Scans a directory recursively and searches for any files newer that 14 days and lists them in a text file. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Date.au3> #include <file.au3> #include "RecFileListToArray.au3" Global $NowTime = _NowCalc(), $Time ;Gets the current date and time Global $Folder = "B:\ServerFolders" ;Global $Folder = FileSelectFolder("Select", "") ;Testing only Global $Files = _RecFileListToArray($Folder, "*", 0, 1, 0, 1, "*.db;*.pst;*.rwz;*.ini;*.jpg;*.dat;*.tmp;*.configdat;*.cc;*.txt", "Client Computer Backups;Documents;Misc Files;Networking Stuff;Private;Pictures;School;Users") ;Adds the files from the folder selected to an array Global $FilteredFiles[$Files[0]][2] Local $File = (@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt") For $iFile = 1 To $Files[0] $Time = FileGetTime($Folder & "\" & $Files[$iFile], 0) If _DateDiff("D", $Time[0] & "/" & $Time[1] & "/" & $Time[2] & " " & $Time[3] & ":" & $Time[4] & ":" & $Time[5], $NowTime) < 14 Then ;created more than 14 days ago $FilteredFiles[$FilteredFiles[0][0] + 1][0] = $Time[2] & StringUpper(_DateToMonth($Time[1], 1)) & $Time[0] $FilteredFiles[$FilteredFiles[0][0] + 1][1] = $Files[$iFile] $FilteredFiles[0][0] += 1 EndIf ;The above formula tells the program to find anything in the array that is older than 14 days and discard it Next ReDim $FilteredFiles[$FilteredFiles[0][0] + 1][2] ;Resize array FileOpen($File, 2) If $File = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($File, "Updated on " & $NowTime & @CRLF & @CRLF) ;Add header to text file with time it was updated FileWriteLine($File, "This file is automatically generated everyday at midnight and noon" & @CRLF & @CRLF) _FileWriteFromArray($File, $FilteredFiles, 2, 0, " < Creation --- Location > ") ;Write array to the text file FileClose($File) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Anime", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Homemade Programs", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Installers", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Kids Movies", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Music", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\New Downloads", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Recorded TV", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Videos", 1) FileCopy(@ScriptDir & "\00-READ ME FIRST - NEWEST FILES LISTED WITHIN.txt", $Folder & "\Workout Programs", 1) Exit Any 10 lb brains out there that can lend a hand for a few minutes. I checked all the include files and they are good, and also checked all directories and they are good, I'm currently at a loss on this one guys please help Link to comment Share on other sites More sharing options...
Mat Posted January 31, 2013 Share Posted January 31, 2013 I'd just increase the array size by one, then try. Usually you're out by one and it's faster to check by running than actually working out what you've done wrong. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Haagimus Posted January 31, 2013 Author Share Posted January 31, 2013 (edited) I'll give that a shot and see if it fixes it [EDIT] Alright I have been out of the code for a few months now, read the includes and checked out a few other forums, how do I increase the array size again.....I feel dumb for asking lol Edited January 31, 2013 by Haagimus Link to comment Share on other sites More sharing options...
Mat Posted January 31, 2013 Share Posted January 31, 2013 I'll give that a shot and see if it fixes it [EDIT] Alright I have been out of the code for a few months now, read the includes and checked out a few other forums, how do I increase the array size again.....I feel dumb for asking lol I'd try changing this line: Global $FilteredFiles[$Files[0]][2] To Global $FilteredFiles[$Files[0] + 1][2] AutoIt Project Listing Link to comment Share on other sites More sharing options...
Haagimus Posted January 31, 2013 Author Share Posted January 31, 2013 (edited) testing nowNew Files TXT output.au3 (22) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $FilteredFiles[$FilteredFiles[0][0] + 1][1] = $Files[$iFile] ^ ERRORSame error different line now Okay now I have a new error that is not in my code?C:\Program Files (x86)\AutoIt3\Include\file.au3 (272) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $s_Temp &= $s_Delim & $a_Array[$x][$y] $s_Temp &= $s_Delim & ^ ERRORI don't really want to go messing around with an include file so what should I do Edited January 31, 2013 by Haagimus Link to comment Share on other sites More sharing options...
guinness Posted January 31, 2013 Share Posted January 31, 2013 (edited) Strange because that line doesn't even appear in the code you provided above. Use the following commands to check if the array is in bounds or search _IsInBounds too. UBound ReDim If Mat has explained the issue, imagine you have a table with 10 rows and you're trying to check the 11th row, which doesn't exist. So you need to work out your logic on accessing the array data. Edited January 31, 2013 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Haagimus Posted February 3, 2013 Author Share Posted February 3, 2013 I have not had a chance to try this to see the result the last few days I have been swamped at work and with school. I will try to test this out next week and get back to you guys Link to comment Share on other sites More sharing options...
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