lbrtdy Posted August 11, 2010 Share Posted August 11, 2010 (edited) The purpose of the script is to automate the process of writing a .bat script. It recursively writes in the lines of all the folders that exists within a certain directory to the batch file. The script keeps on erroring at lines 20 and 36 where the "for $i = 1 to $FolderList[0] begins" saying that "Subscript used with non-Array variable" while it is. While I see it as an Array variable :S any help will be great, thanks! expandcollapse popup#include <File.au3> #include <Array.au3> Dim $Directory = @ScriptDir if FileExists(@ScriptDir & "\SUpdate.bat") Then FileDelete(@ScriptDir & "\SUpdate.bat") EndIf $file = FileOpen("SUpdate.bat",1) FileWriteLine($file,"@echo off") FileWriteLine($file,"pause") FileWriteLine($file,"rem --- SBOT Folders ---") $FolderList = _FileListToArray($Directory,"",2) if @error = 4 Then MsgBox(0,"Error", "No Folders were found!") EndIf $FolderNumber = 1 for $i = 1 to $FolderList[0] FileWriteLine($file,"set" & "" & $FolderNumber & "=" & $FolderList[$i]) $FolderNumber += 1 Next FileWriteLine($file,"") ;Extra space FileWriteLine($file,"") ;Extra space FileWriteLine($file,"rem --- Extract ---") FileWriteLine($file,"cd c:\program files\7-zip") FileWriteLine($file,"7z x -o%temp%\temp %1 -xr!Scripts -y") FileWriteLine($file,"set extracted=%temp%\temp") FileWriteLine($file,"rem -- Copy --") FileWriteLine($file,"") ;Extra space FileWriteLine($file,"") ;Extra space $FolderNumber2 = 1 for $i = 1 to $FolderList[0] FileWriteLine($file,"cd" & $FolderNumber2) FileWriteLine($file,"Del SBot*.exe") FileWriteLine($file,"echo Copying New files...") FileWriteLine($file,"xcopy %extracted% %folder1% /V /Y /E") $FolderNumber2 += 1 Next FileWriteLine($file,"rem --- Delete Temp/Left over files ---") FileWriteLine($file,"echo deleting temp files . . .") FileWriteLine($file,"rd /s /q %extracted%") FileWriteLine($file,"echo deleting original zip file . . .") FileWriteLine($file,"del %1") FileWriteLine($file,"echo finished") FileClose($file) Edited August 11, 2010 by lbrtdy Link to comment Share on other sites More sharing options...
JohnOne Posted August 11, 2010 Share Posted August 11, 2010 You should do some debugging if @error Then MsgBox(0,"Error", "Error No : " & @error) EndIf see if its an error other than #4 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
taietel Posted August 11, 2010 Share Posted August 11, 2010 (edited) Line 15 should be: $FolderList = _FileListToArray($Directory,"*",2) And Line 5: $Directory=@ScriptDir & "\" Edited August 11, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
lbrtdy Posted August 11, 2010 Author Share Posted August 11, 2010 (edited) You should do some debugging if @error Then MsgBox(0,"Error", "Error No : " & @error) EndIf see if its an error other than #4 Oh wow silly mistake lol. Thank you very much JohnOne everything works as a charm! (with taietel's adjustments too thx!) Edited August 11, 2010 by lbrtdy Link to comment Share on other sites More sharing options...
taietel Posted August 11, 2010 Share Posted August 11, 2010 Ibrtdy, what JohnOne wrote was just for debugging. It gives you error=2 that doesn't solve your problem! Run your script and see for yourself.Make adjustments in that line I stated above, and run again. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text 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