waiting for files to finish transfering... how to know when?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
IXIS

waiting for files to finish transfering... how to know when?

Post by IXIS » Tue Aug 17, 2004 9:07 pm

Hello Gang,

I have a question for anyone out there that is willing to answer it. I put together a script that has to pick up new audio files (always named differently) from remote servers every hour, process them and then move them over to an archived directory for later use. Originally, my idea was to do this all on a strict time schedule, but I am know noticing that the difference in speeds of each of these remote boxes makes that a little sketchy. Now I'm thinkng that it would be best to look for the last modified file, and wait untill it was 2 minutes old (if nothing has been downloaded in 2 minutes the job is done) before giving the command to start processing. Anyone have any idea how I would do this? I have seen a few of the scripts in the scripts and tips that go over last modified, but they still leave me a little short. Basicly, I would need to...

Get newest modified file time
Get Current Time
If file time is older than 2 minutes, jump

label>jump
start processing.....

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Aug 17, 2004 11:37 pm

How about counting files?
It may be easier than trying to id the file with the latest time.
If count has not changed, then done. Something like this?
Label>Start
GetFileList>c:\temp\*.*,files
Separate>files,;,file_names

Label>CheckCount
Let>CountNow=%file_names_count%
Wait>120
GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
If>%file_names_count%=%CountNow%,jump,CheckCount

label>jump
start processing.....
Note: The code above is free form, untested. Remember if you Cut/Paste from the forum to remove any trailing space characters. You can do this in the Editor. Click on Edit, Show All Chars, and Remove Trailing Spaces.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

IXIS

Post by IXIS » Wed Aug 18, 2004 12:52 am

Thanks Bob. Apreciate the help. I thought of the counting files thing, but anytime there is a reboot or any other system work to the remote boxes, the file count will change.

I wouldn't need to do this if the speed of the file transfers were always the same, but we all know how that goes. Is there any other way to tell when the file transfers are over?

-Terry

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Aug 18, 2004 1:43 am

Is there any other way to tell when the file transfers are over?
When the copy process is happening it is probably in a Window. Some windows are invisible but still open. If you can get the window name, you could wait until the window was closed. You can use Tools, View System Windows from the Menu Bar on the Macro Scheduler main screen.

For example this would wait 5 minutes for the Window to Close. If not closed by itself it will close itself:
Let>WW_TIMEOUT=300
Let>WF_TYPE=1
WaitWindowClosed>FileCopyWindow*
If>WW_RESULT=FALSE,StillOpen
..
..
Label>StillOpen
Message>Window for copying files is still open. Macro continuing.
Check out the WaitWindowClosed> command in the Help section.

============================
You could also consider running the Copy Sound Files routine using the Run Program> command along with RP_WAIT=1. This will run the program noted, and halt macro processing until that program is completed. Then macro processing will continue. (Setting RP_WAIT=0 will start the program, and continue the macro without waiting for the called program to finish). I think it's a good practice to toggle the RP_WAIT variable immediately after the Run Program command.
Let>RP_WAIT=1
Run Program>command.com /c CopyFiles.exe
Let>RP_WAIT=0

Label>jump
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

IXIS

Post by IXIS » Wed Aug 18, 2004 2:04 am

When the copy process is happening it is probably in a Window. Some windows are invisible but still open.
I think this is my answer. Thanks so much for the help. First time in ages i've messed with any type of code/script. I'll check the system window idea out tomorrow at the office and let you know how it went. :lol:

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts