nonplayablecharacter Posted August 21, 2008 Share Posted August 21, 2008 (edited) Can anyone tell me why MOST of the time im getting a message saying i have too many subscript or range is exceeded even though i have 'if not @ error then'it happens at lines:9.DirRemove("C:\Test1\" & $Dir[$num], 1)--------------------------->happens if no folders exist____________________________^Array too many or too high18.FileDelete("C:\Test1\" & $Dir2[$num2])----------------------------->happens after creating a folder in the directory_____________________________^Array too many or too highPictures at bottomCODE#include <File.au3>While 1 $Dir=_FileListToArray ( "C:\Test1" , "*", 2)If not @error Then$num=1DoDirRemove("C:\Test1\" & $Dir[$num], 1)$num=$num+1until $num=$Dir[0]+1EndIf$Dir2=_FileListToArray ( "C:\Test1" , "*", 1)If not @error Then$num2=1DoFileDelete("C:\Test1\" & $Dir2[$num2])$num2=$num2+1until $num2=$Dir2[0]+1EndIfWendPS: It's even worse without do...until because there needs to be "# of folders=# of files" which is almost impossible Edited August 21, 2008 by nonplayablecharacter You can always count on me for the dumb questions ;)My Scripts:Rikku Link to comment Share on other sites More sharing options...
zorphnog Posted August 21, 2008 Share Posted August 21, 2008 I'm not sure why you have all of this in a While loop, but thats beside the point. Ever used a For...To... loop? #include <File.au3> While 1 $arDirs = _FileListToArray ( "C:\Test1" , "*", 2) If Not @error Then For $i=1 To $arDirs[0] DirRemove("C:\Test1\" & $arDirs[$i], 1) Next EndIf $arFiles = _FileListToArray ( "C:\Test1" , "*", 1) If Not @error Then For $i=1 To $arFiles[0] FileDelete("C:\Test1\" & $Dir2[$i]) Next EndIf Wend Link to comment Share on other sites More sharing options...
Valuater Posted August 21, 2008 Share Posted August 21, 2008 maybe.... #include <File.au3> $Location = @ScriptDir & "\" ; "C:\Test1" $Dir = _FileListToArray($Location, "*", 2) For $x = 1 To $Dir[0] $Files = _FileListToArray($Location & $Dir[$x] & "\", "*", 1) For $i = 1 To $Files[0] ;FileDelete($Location & $Dir[$x] & "\" & $Files[$i]) ConsoleWrite("deleted file - " & $Location & $Dir[$x] & "\" & $Files[$i] & @CRLF) Next ;DirRemove($Location & $Dir[$num], 1) ConsoleWrite("> dir removed - " & $Location & $Dir[$x] & @CRLF) Next you have to remove the files first AFAIK.. 8) 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