Notifications
Clear all

[Closed] to get the most recent file

[left]AA_BB_V01_01.max[/left]
AA_BB_V01_02.max
AA_BB_V02_01.max
AA_BB_V02_02.max

[left]How can I get the most recent file(AA_BB_V02_02.max) among those files?[/left]

2 Replies

I’d check the date the files where created/modified, store the information in an array and get the max value.

[left]getFileModDate <filename_string>
[/left]
[left]Returns a String value containing the modification date for the specified file, for example “1/29/99 1:52:05 PM”.
[/left]
[left]
[/left]
[left]getFileCreateDate <filename_string>
[/left]
[left]Returns a String value containing the creation date for the specified file.
[/left]


   a = #("3/5/2008 2:20:09 PM", "3/6/2008 2:26:03 PM", "3/6/2008 6:23:05 PM")
   #("3/5/2008 2:20:09 PM", "3/6/2008 2:26:03 PM", "3/6/2008 6:23:05 PM")
   amax a
   "3/6/2008 6:23:05 PM"

Hi,

If your nameing scheme is strict (like in your example above) you could put them all in an array and sort it:


(
	local files = #("AA_BB_V01_02.max","AA_BB_V02_02.max","AA_BB_V01_01.max","AA_BB_V02_01.max")
	sort files
	files[files.count]
)

If the most recent file is also the most recent by date, you might want to look into sorting by date instead.

hOpe this helps,
o