Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Determining When a File Is Ready
#1
When I copy files from another computer on the local LAN, the source file may still be being copied or downloaded (the file size is changing).

The method in the code below may be too simplistic.

Is there a more accurate way to determine whether the file is ready?

I have seen similar code in a macro on a forum, but after trying many keywords, I still haven't found it.

Function Function6
Code:
Copy      Help
str destFolder="$desktop$\T"
mkdir destFolder

sub.netCopy("\\PC001\d\S" destFolder)

#sub netCopy
function ~srcFolder ~dstFolder
,;; Get full path list of .avi and .mp4 files
,ARRAY(str) a
,GetFilesInFolder a srcFolder "*.avi[]*.mp4"
,
,int i
,for i 0 a.len
,,str filePath = a[i]
,,
,,;; Wait for file size to stabilize (max 60 seconds)
,,int prevSize = -1
,,int curSize
,,int waited = 0
,,rep
,,,Dir d.dir(filePath)
,,,curSize = d.FileSize
,,,if(prevSize != -1 and curSize = prevSize) break
,,,prevSize = curSize
,,,waited + 2
,,,if(waited >= 60) break
,,,2   ;; wait 2 seconds
,,
,,;; Copy file (replace if target exists)
,,cop- filePath dstFolder


Messages In This Thread
Determining When a File Is Ready - by Davider - 09-01-2026, 05:10 AM
RE: Determining When a File Is Ready - by Davider - 09-01-2026, 07:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)