mnchartier Posted March 5, 2008 Posted March 5, 2008 I found this a while back and have used it in a backup script and has work great at doing a complete directory and subdirectories file list. The problem now is that I want to try it to backup a few network devices and I am using a for next statement that goes through an array of about 10 devices to get the file list from and then check to make sure the file exists on the backup drive and if not copy it. The problem I have is that there is an If statement that looks to see if an object was declared and this is what is giving me the hiccup in this script. The first device is fine but then when it runs for the second device it does not go through the reinitialization of the object and gives an error: C:\Documents and Settings\mchartier\My Documents\Scripts\backuptesting.au3 (49) : ==> Variable must be of type "Object".: For $Subfolder in $rootFolder.SubFolders For $Subfolder in $rootFolder^ ERROR Here is what I have in that function I have tried to close the object and also change from IsDeclared to IsObj after closing the object. With the IsObj it seems to be in a complete loop it never returns the list. Func _AdvancedFileListToArray($sPath, $rootFolder = '') If NOT IsDeclared("objFSO") Then Global $objFSO = ObjCreate("Scripting.FileSystemObject") $AFLTfilecount = DirGetSize ($sPath,1) Global $objArray[$AFLTfilecount[1] + 1] $rootFolder = $objFSO.GetFolder($sPath) For $objFile in $rootFolder.Files $objArray[$objArray[0] + 1] = $sPath & "\" & $objFile.Name $objArray[0] += 1 Next EndIf For $Subfolder in $rootFolder.SubFolders $objFolder = $objFSO.GetFolder($Subfolder.Path) For $objFile in $objFolder.Files $objArray[$objArray[0] + 1] = $Subfolder.Path & "\" & $objFile.Name $objArray[0] += 1 Next _AdvancedFileListToArray($sPath, $Subfolder) Next Return $objArray $objFSO.close EndFunc I do not remember exactly where or who I got the function from.
weaponx Posted March 5, 2008 Posted March 5, 2008 (edited) Most likely got it here:http://www.autoitscript.com/forum/index.ph...c=58558&hl=Its one of least efficient ways of getting a file list to an array. Notice there is error control in the script as it is merely proof-of-concept. Edited March 5, 2008 by weaponx
mnchartier Posted March 5, 2008 Author Posted March 5, 2008 Yes that is the posting I got it from. I have been trying to edit the function so that the object gets destroyed after the first device was backed up and go to the next, that is where the error comes from
weaponx Posted March 5, 2008 Posted March 5, 2008 I would avoid using that function, instead use the RecursiveFileSearch function at the bottom of post #1. #include <Array.au3> ;Find all files in desired folder recursively $result = RecursiveFileSearch(@DesktopDir & "\Test", "", "", 1) _ArrayDisplay($result)
mnchartier Posted March 5, 2008 Author Posted March 5, 2008 I have tried that now, on one of the devices there are over 6000 files returned and for some reason when I view the array anything from 3998 on the value is in the same column as the row number
weaponx Posted March 5, 2008 Posted March 5, 2008 I have tried that now, on one of the devices there are over 6000 files returned and for some reason when I view the array anything from 3998 on the value is in the same column as the row number_ArrayDisplay has a limit of 4000 items, which I think is a ListView limitation.
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