kor Posted April 2, 2015 Share Posted April 2, 2015 (edited) #include <Array.au3> #include <File.au3> #include <FileConstants.au3> ;$aFiles = _FileListToArrayRec("\\express.mpsaz.org\purchasing", "*", $FLTA_FILES, $FLTAR_RECUR) ;_ArrayDisplay($aFiles) ;1246 Do $aFiles = _FileListToArrayRec("C:\temp", "*", $FLTA_FILES, $FLTAR_RECUR) Sleep(500) $iOldFiles = $aFiles[0] ConsoleWrite("old files = " & $iOldFiles & " new files = " & $aFiles[0] & @CR) Until $iOldFiles < $aFiles[0] ConsoleWrite("out of the loop" & @CR) The goal is to monitor a directory and wait. as soon as a new file appears exit the loop (need help here) then copy the file to a new directory (haven't got there yet) then continue back into the loop and keep monitoring I'm stuck on how to approach this. I'm not good with Do until loops. What I'm attempting to do in the code is list all files in a directory, count the number of files.. and if the number of files increases (by any number) then do an action... once the action is done.. continue back into the loop. get number of files in a directory if # of files in directory increases from the last time you got the # of files then copy the file to XYZ then go back to the beginning and keep getting the number of files in a directory. EDIT: I'm not even sure a Do Until loop is right for me. My biggest issue is I don't know how to compare the number of files that is in the CURRENT loop to the number of files that was in the LAST loop that just completed. So if the last time the loop finished the number of files was 105, and now in the current loop the number of files is 106, how do I have the number of files from the last loop survive the loop into the next one? Edited April 2, 2015 by kor Link to comment Share on other sites More sharing options...
Solution kor Posted April 2, 2015 Author Solution Share Posted April 2, 2015 (edited) Maybe something like this? #include <Array.au3> #include <File.au3> #include <FileConstants.au3> While 1 Sleep(2000) ; slow things down so you can see it $aFiles = _FileListToArrayRec("C:\temp", "*", $FLTA_FILES, $FLTAR_RECUR, 0, $FLTAR_FULLPATH) If @error Then ContinueLoop If $aFiles[0] > 0 Then For $i = 1 To UBound($aFiles) - 1 FileMove($aFiles[$i], "C:\temp1", $FC_OVERWRITE) Next EndIf WEnd Edited April 2, 2015 by kor Link to comment Share on other sites More sharing options...
JohnOne Posted April 3, 2015 Share Posted April 3, 2015 Take a look at this '?do=embed' frameborder='0' data-embedContent>> 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...
kor Posted April 3, 2015 Author Share Posted April 3, 2015 Take a look at this '?do=embed' frameborder='0' data-embedContent>> I don't believe that will work. The file path that I need to monitor is on an IBM iSeries AS400 and isn't a windows file system. Link to comment Share on other sites More sharing options...
JohnOne Posted April 3, 2015 Share Posted April 3, 2015 I'm surprised AutoIt runs on a non windows file system. 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...
nitekram Posted April 3, 2015 Share Posted April 3, 2015 Maybe something like this? #include <Array.au3> #include <File.au3> #include <FileConstants.au3> While 1 Sleep(2000) ; slow things down so you can see it $aFiles = _FileListToArrayRec("C:\temp", "*", $FLTA_FILES, $FLTAR_RECUR, 0, $FLTAR_FULLPATH) If @error Then ContinueLoop If $aFiles[0] > 0 Then For $i = 1 To UBound($aFiles) - 1 FileMove($aFiles[$i], "C:\temp1", $FC_OVERWRITE) Next EndIf WEnd I think that should work. Are you not getting the results? The OP code, will never work, as you keep making the value the same and then checking to see if one is larger than the other. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator 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