我需要在Mac上以编程方式获取文件名,使用Selenium下载文件,从下载文件夹我需要选择相同的文件以编程方式安装,我正在使用Applescript执行相同的操作。我坚持在运行时获取文件名,我的下载页面url也不包含下载文件的全名。请建议..
答案 0 :(得分:2)
这将为您提供下载文件夹的最新文件(按创建日期排序):
tell application "Finder"
set latestFile to item 1 of (sort (get files of (path to downloads folder)) by creation date) as alias
set fileName to latestFile's name
end tell
答案 1 :(得分:1)
是的,Mavericks会打开最旧的,但是通过指定最后一项来实现这种接缝。
tell application "Finder"
set latestFile to last item of (sort (get files of (path to downloads folder)) by creation date) as alias
set fileName to latestFile's name
end tell