09-01-2026, 05:10 AM
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
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
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