pendal Posted April 17, 2009 Share Posted April 17, 2009 (edited) I need to return the directories within an directory into an array to be used in a loop. I am used to coding in PHP and Javascript. in other words Dim $baseDir, $dirArray $dirArray = get directory list from $baseDir foreach($dirArray){ do something } Can I have some help translating that into autoit code? I looked through the function list and can't find anything about listing directory contents. in PHP i would use the command scandir(). Basically I need to go into each of those directories and do file maintenance. Thanks in advance. -P Edited April 17, 2009 by pendal Link to comment Share on other sites More sharing options...
LurchMan Posted April 17, 2009 Share Posted April 17, 2009 (edited) This should work for you. #include <File.au3> Global $array $array = _FileListToArray($sPath, "*", 2) ;$sPath = path to dir, "*" is wildcard saying all files, and the 2 means return folders only For $n = 0 To UBound ($array) - 1 ;do something... Next Look under File Management in the help file for more information. Edit: Added for loop code Edited April 17, 2009 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
pendal Posted April 17, 2009 Author Share Posted April 17, 2009 Look under File Management in the help file for more information.Thank you so much! .. this will make my friday go much faster. Link to comment Share on other sites More sharing options...
erik7426 Posted April 17, 2009 Share Posted April 17, 2009 I need to return the directories within an directory into an array to be used in a loop. I am used to coding in PHP and Javascript. in other words Dim $baseDir, $dirArray $dirArray = get directory list from $baseDir foreach($dirArray){ do something } Can I have some help translating that into autoit code? I looked through the function list and can't find anything about listing directory contents. in PHP i would use the command scandir(). Basically I need to go into each of those directories and do file maintenance. Thanks in advance. -P #Include <File.au3> #Include <Array.au3> $DirList = _FileListToArray(@DesktopDir, "*", 2) For $i = 1 to $DirList[0] MsgBox(0,@DesktopDir,"'" & $DirList[$i] & "' is a folder located in " & @DesktopDir) Next ;or _ArrayDisplay($DirList) That should do what you need...just sub @DesktopDir with whatever folder you want to search... 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