ale1981 Posted July 30, 2008 Share Posted July 30, 2008 I would like to loop through files in a directory and depending on the created date, move the file to a different directory based on its created date. I know how to retrieve the created date of a file, what I do not know is how to loop through all the files in the directory one by one? Any help appreciated. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 30, 2008 Moderators Share Posted July 30, 2008 I would like to loop through files in a directory and depending on the created date, move the file to a different directory based on its created date.I know how to retrieve the created date of a file, what I do not know is how to loop through all the files in the directory one by one?Any help appreciated._FileListToArray() yyywww 1 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ale1981 Posted July 30, 2008 Author Share Posted July 30, 2008 Thanks for your prompt response. How do i now loop through the files in that array, i need to loop through the array apart from the first element in the array as that is the number of files? Link to comment Share on other sites More sharing options...
DMEE Posted July 30, 2008 Share Posted July 30, 2008 The autoit help file is a very useful resource to find answers to this kind of questions. Just search on loop statements and you'll most probably find your answer. If you have any errors or questions, look on the forum and the help file, if this does not solve your question, then post a piece of code where the error occurs. People here tend to be more extended in their answers if one shows that he tried to resolve the problem himself first In the beginning there was nothing and then even that exploded - anonymous Link to comment Share on other sites More sharing options...
ale1981 Posted July 30, 2008 Author Share Posted July 30, 2008 Hi DMEE, I have searched the help file for While WEnd loop statements, but I am unsure on how to loop through the array, skipping the first element? The help file says; $i = 0 While $i <= 10 MsgBox(0, "Value of $i is:", $i) $i = $i + 1 WEnd Link to comment Share on other sites More sharing options...
DMEE Posted July 30, 2008 Share Posted July 30, 2008 (edited) I guess that the loop statement that you need is: For ... Next or For ... In ... Next for example: $array = _FileListToArray() For $i = 1 to $array[0] statements Next Edit: your code could work if you start with $i = 1 as initialisation variable. In the loop you can use the variable $i to acces the array element with $array[$i] Edited July 30, 2008 by DMEE SkysLastChance 1 In the beginning there was nothing and then even that exploded - anonymous Link to comment Share on other sites More sharing options...
ale1981 Posted July 30, 2008 Author Share Posted July 30, 2008 Ok, i have the following code which works great, but how do I skip the first element of the array in my for next loop as it is not a file? #Include <File.au3> #Include <Array.au3> #Include <_XMLDomWrapper.au3> $xml_path_in = "\\pathto\ArchiveIn\" $FileList = _FileListToArray($xml_path_in, "*", 1) For $fileInf in $FileList MsgBox(64, "", $fileInf) Next Link to comment Share on other sites More sharing options...
herewasplato Posted July 30, 2008 Share Posted July 30, 2008 #include <File.au3> $FileList = _FileListToArray(@DesktopDir) If @error = 1 Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf For $i = 1 To $FileList[0] MsgBox(0, $i, $FileList[$i]) Next [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
DMEE Posted July 30, 2008 Share Posted July 30, 2008 For $fileInf in $FileList If IsString($fileInf) Then MsgBox(64, "", $fileInf) Endif Next In the beginning there was nothing and then even that exploded - anonymous Link to comment Share on other sites More sharing options...
ale1981 Posted July 30, 2008 Author Share Posted July 30, 2008 Thanks everybody for your replies. I will use the following; #Include <File.au3> #Include <Array.au3> #Include <_XMLDomWrapper.au3> $path = "C:\Temp\" $xml_path_in = $path & "ArchiveIn" $FileList = _FileListToArray($xml_path_in, "*", 1) For $i = 1 to $FileList[0] MsgBox(64, "", $FileList[$i]) Next 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