I’m getting the following error in my AutoIt script:
“Array variable subscript badly formatted.”
and it is thrown on this line: Local $allDirs[$countDirs]
Func archiveDir($dir)
; Get all the files under the current dir
$allOfDir = _FileListToArray($dir)
Local $countDirs = 0
Local $countFiles = 0
$imax = UBound($allOfDir)
For $i = 0 to $imax - 1
If StringInStr(FileGetAttrib($allOfDir[$i]),"D") Then
$countDirs = $countDirs + 1
Else
$countFiles = $countFiles + 1
EndIf
Next
Local $allDirs[$countDirs]
Local $allFiles[$countFiles]
Any ideas?
I’m guessing you either don’t have any subdirectories or your code to find them isn’t working correctly. So your code is trying to declare an array of 0 length.
Add this line right before the line where you get the error.
UPDATE
_FileListToArrayonly returns the file/folder names, not the full path. The call toFileGetAttribis returning an empty string because it does not find the file/folder. Modify yourIfto include the parent path with the file name.