如何以编程方式使用applescript获取最新下载的文件名? [英] How to get the latest downloaded file name with applescript programatically?

查看:26
本文介绍了如何以编程方式使用applescript获取最新下载的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Mac 上以编程方式获取文件名,我使用 Selenium 下载文件,我需要从下载文件夹中选择相同的文件以编程方式安装,我使用 Applescript 来执行相同操作.我在运行时无法获取文件名,而且我的下载页面 url 不包含下载文件的全名.请建议..

I need to get the file name programatically on Mac, am using Selenium to download the file and from downloads folder i need to pick the same file to install programatically, am using Applescript to do the same. I am stuck in getting the file name in runtime, also my download page url doesnot contain full name of the download file. Pls suggest..

推荐答案

这将为您提供下载文件夹的最新文件(按创建日期排序):

This will give you the latest file (sorted by creation date) of your downloads folder:

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

这篇关于如何以编程方式使用applescript获取最新下载的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆