Here are a few custom functions I have used in the past that may be useful to others. The first is a rather robust function that gathers all instances of a file or folder and lists them in chronological order. It uses a shellscript( using mdfind and gets the list of file paths then an arrayfilter( adds on the superdate of the last date modified for each database path followed by an arraynumericsort( to get them in chronological order with a final arrayfilter to convert the superdate to a text pattern for date and time modified. A file name must include the extension but there is no need to match the case for a file or folder name.
registercustomfunction "LOCATEFILES",1,{arrayfilter(arraynumericsort(arrayfilter(shellscript(
||| mdfind "kMDItemFSName='|||+?(•1="",info("databasefilename"),•1)+|||'"|||)
,cr(),||| superdate(val(nthline(fileinfo(import()),5)),
val(nthline(fileinfo(import()),6)))+tab()+import() |||),cr()),cr(),
|||superdatestr(val(arrayfirst(import(),tab())))+tab()+arraylast(import(),tab()) |||)}
In use:
let x= locatefiles("Logo.gif")
Returns this on my computer:>
11/17/03 12:43 PM /Users/garyyonaites/Documents/Archive/Pratchettes Help/Logo.gif
10/19/04 6:49 AM /Users/garyyonaites/Documents/Archive/Documents/PratchettesX/Logo.gif
10/19/04 6:49 AM /Users/garyyonaites/Documents/Archive/Pratchettes Archive/Logo.gif
10/19/04 6:49 AM /Users/garyyonaites/Documents/unseensoft.com/PratchettesX/Logo.gif
10/22/04 1:41 PM /Users/Shared/Previously Relocated Items/Security/Pratchettes Help/Logo.gif
10/22/04 1:41 PM /Volumes/Alt SSD/Users/Shared/Security/Pratchettes Help/Logo.gif
11/21/18 10:23 AM /Users/garyyonaites/Documents/Logo.gif
11/21/18 10:23 AM /Users/garyyonaites/iCloud Drive (Archive)/Documents/Logo.gif
Here are two additional simple custom functions that will get either the maximum or minimum number from a text array of numeric values.
ArrayNumericMax:
registercustomfunction "ARRAYNUMERICMAX",2,||| arraylast(arraynumericsort(•1,•2),•2) |||
ArrayNumericMin:
registercustomfunction "ARRAYNUMERICMIN",2,||| arrayfirst(arraynumericsort(•1,•2),•2) |||