Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

trouble with a do until loop

$
0
0
#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?


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>