Posts: 111
Threads: 31
Joined: Sep 2014
I did some searching and sorry to ask this IF in fact it has already been answered.
How can I find the oldest file in a folder?
Example would be great!
Thanks for any suggestions
Kent
Posts: 12,072
Threads: 140
Joined: Dec 2002
Macro
Find oldest file in folder
str folder="$my qm$"
str fileName ;;can be eg = "*.txt"; finds all if empty
ARRAY(str) a
GetFilesInFolder a folder fileName 64 2
if(!a.len) out "no files"; ret
a.sort
;out a
DateTime t=val(a[0] 1 _i)
t.UtcToLocal
str sPath=a[0]+_i+1
out F"{sPath} {t.ToStr(4)}"
Posts: 111
Threads: 31
Joined: Sep 2014
Gintaras, THANKS! = will try this! I tell all my friends who may have a need for macros about Quick Macros!!!
Posts: 111
Threads: 31
Joined: Sep 2014
Gintaras, I KNOW you are busy, but could you tell me 'what' actually determines what file is oldest in the code you shared. This will help me in the long run understand this element of the programming language. THANKS!!!!!!!
Posts: 12,072
Threads: 140
Joined: Dec 2002
GetFilesInFolder with getProp 2 prepends file times to file paths in the array. Then we sort, and the smallest number is in the first element.