I need to find the largest txt from as many as 82 files
The list of txt files are on my c: drive and named file#.txt
Where # could be 1 through 82.
Right not there are 3 files and I need to find the largest of them to process in Access.
It's highly unlikely that there will ever be more then 10 files but I need the flexibility just in case.
There will always be 1 file that is larger.
The file sizes are as follows:
file1.txt = 977332
file2.txt = 1004264
file3.txt = 890090
Getting the FileSize is easy.
The part I'm having trouble with is finding the largest one.
It should be easy but my brain will not cooperate this morning.
This is what I have so far.
let>x=3 //file count from another part of the script, just put here to test
Let>e=1
Repeat>e
FileSize>C:\file%e%.txt,FileSize%e%
Let>f%e%=FileSize%e%
Let>e=e+1
Until>e>x
If>x=1
Let>CF_OVERWRITE=1
CopyFile>C:\file1.txt,u:\file.txt
exit
EndIf
//copy largest file to u:\file.txt
Thank you for your help!
Help finding largest file
Moderators: Dorian (MJT support), JRL
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
What about this...
Code: Select all
GetFileList><folder>\*.*,FileList,|
Separate>FileList,|,FileArr
Let>LargestFile=FileArr_1
FileSize>FileArr_1,nFileSize
Let>LargestFileSize=nFileSize
Let>cnt=1
Repeat>cnt
FileSize>FileArr_%cnt%,nFileSize
If>nFileSize>LargestFileSize
Let>LargestFile=FileArr_%cnt%
Let>LargestFileSize=nFileSize
Endif
Let>cnt=cnt+1
Until>cnt,FileArr_Count
MDL>Largest File: %LargestFile%, Size: %LargestFileSize%
You are my hero!
Beautifully simple!!
That is exactly what I was wanting to do but I've never worked with arrays before.
It works perfectly on my test set of files.
THANK YOU!!!
That is exactly what I was wanting to do but I've never worked with arrays before.
It works perfectly on my test set of files.
THANK YOU!!!