如何使用苹果脚本获取文件夹中最新创建的文件的路径?

How do I get the Path to the latest created file in a folder with apple script?

我想获取在文件夹 test 中创建的最后一个文件的路径

set p to "/Users/palmglow/Documents/googledrive/orders/IFTTT/test"
set a to POSIX file "/Users/palmglow/Documents/googledrive/orders/IFTTT/test/"
set latestFile to last item of (sort (get files of (POSIX file "/Users/palmglow/Documents/googledrive/orders/IFTTT/test")) by creation date) as alias

尝试:

set myFolder to "/Users/palmglow/Documents/googledrive/orders/IFTTT/test"
tell application "Finder" to set latestFile to item 1 of (sort files of (POSIX file myFolder as alias) by creation date) as alias