Moving Completely Transfered files

I have a driectoty called TEMP on server 1.There is a process running on another server which is pushing files in this directory of server 1.
I want to write a script which will move the files from TEMP directory to TEMP2 directory on server 1 only but make sure that it will only copy those files which have been transferred completley from server 2 i.e. it should not move files from TEMP to TEMP2 which are currently being pushed from server 2 as the data will be corrupted.
How can i know if the file is being accessed in shell script?

There may well be much more elegant ways of doing this but I have done this in the dim and distant past by simply looking at the files over a period of time - say one minute - and if the mtime and size have not changed then you can be pretty well sure the transfer has finished.

Possibly a better way would be to identify the process doing the transfer (via its pid via ps) and if/when the process finishes assume the transfer is complete.

*yet* another way would be to get the sending server to transfer a zero length 'flag' file when the transfer has finished. when you see the existance of the flag file you know the transfer has finished.

so

on server2
start send of filename..................send ends (this may take a while)
send finename.flag (0 length - this will take a very short time)

on server1 ensure you remove the flag files as you process the transfered files

Hope this helps

Thanks....I think the first approach is easy one.....what we can do is get filenames and sizes of each file in TEMP directory using ls -ltr command......then sleep for 2 minutes........after 2 minutes get this information again........and move those files which have same size ..........
Can anybody help converting this to sript?