asgarcymed Posted November 14, 2007 Share Posted November 14, 2007 The following VBScript is a very easy demonstration how to make a recursive subroutine/function:CODESet fso = CreateObject ("Scripting.FileSystemObject")pasta_inicial = ("C:\Portable Apps\7-Zip")Set pasta_obtida = fso.GetFolder(pasta_inicial)Wscript.Echo pasta_obtida.PathSet lista_ficheiros = pasta_obtida.FilesFor Each ficheiro In lista_ficheiros Wscript.Echo ficheiro.NameNextWscript.Echolista_sub_pastas fso.GetFolder(pasta_inicial)Sub lista_sub_pastas(pasta) For Each sub_pasta In pasta.SubFolders Wscript.Echo sub_pasta.Path Set pasta_obtida = fso.GetFolder(sub_pasta.Path) Set lista_ficheiros = pasta_obtida.Files For Each ficheiro In lista_ficheiros Wscript.Echo ficheiro.Name Next Wscript.Echo lista_sub_pastas sub_pasta NextEnd SubI tried to convert/translate/adapt it, from VBS to AU3....I did:Dim $fso, $pasta_inicial, $pasta_obtida, $lista_ficheiros, $ficheiro, $lista_sub_pastas, $sub_pasta $fso = ObjCreate("Scripting.FileSystemObject") $pasta_inicial = ("C:\Portable Apps\7-Zip") $pasta_obtida = $fso.GetFolder ($pasta_inicial) FileWrite(@DesktopDir & "\log.log", ($pasta_obtida.Path) & Chr(13)) $lista_ficheiros = $pasta_obtida.Files For $ficheiro In $lista_ficheiros FileWrite(@DesktopDir & "\log.log", ($ficheiro.Name) & Chr(13)) Next $lista_sub_pastas ($fso.GetFolder ($pasta_inicial)) Func lista_sub_pastas($pasta) For $sub_pasta In $pasta.SubFolders () FileWrite(@DesktopDir & "\log.log", ($sub_pasta.Path) & Chr(13)) $pasta_obtida = $fso.GetFolder ($sub_pasta.Path) $lista_ficheiros = $pasta_obtida.Files For $ficheiro In $lista_ficheiros FileWrite(@DesktopDir & "\log.log", ($ficheiro.Name) & Chr(13)) Next $lista_sub_pastas ($sub_pasta) Next EndFunc ;==>lista_sub_pastasHowever I get an error that is putting my brain on fire:« (15) : ==> Unbalanced brackets in expression »What is this; what does it mean; why it is happening????Thanks.Regards. MLMK - my blogging craziness... Link to comment Share on other sites More sharing options...
randallc Posted November 14, 2007 Share Posted November 14, 2007 hi, Not sure; ? try lista_sub_pastas ($fso.GetFolder ($pasta_inicial))R ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
asgarcymed Posted November 14, 2007 Author Share Posted November 14, 2007 ALL give ERROR: lista_sub_pastas ($fso.GetFolder ($pasta_inicial)) lista_sub_pastas ($fso.GetFolder $pasta_inicial) lista_sub_pastas $fso.GetFolder ($pasta_inicial) lista_sub_pastas $fso.GetFolder $pasta_inicial MLMK - my blogging craziness... Link to comment Share on other sites More sharing options...
zfisherdrums Posted November 14, 2007 Share Posted November 14, 2007 Hello asgarcymed, I think what Randallc is saying is: remove the '$' from the beginning of your function calls. When I renamed them "lista_sub_pastas", your code works. lista_sub_pastas ( $fso.GetFolder ($pasta_inicial) ) Func lista_sub_pastas($pasta) For $sub_pasta In $pasta.SubFolders () FileWrite(@DesktopDir & "\log.log", ($sub_pasta.Path) & Chr(13)) $pasta_obtida = $fso.GetFolder ($sub_pasta.Path) $lista_ficheiros = $pasta_obtida.Files For $ficheiro In $lista_ficheiros FileWrite(@DesktopDir & "\log.log", ($ficheiro.Name) & Chr(13)) Next lista_sub_pastas ($sub_pasta) Next EndFunc ;==>lista_sub_pastas Zach... Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
asgarcymed Posted November 14, 2007 Author Share Posted November 14, 2007 Finally my brain can rest in peace Thank you a lot!! Regards. MLMK - my blogging craziness... 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